All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
No meaningful changes since last release.
7.1.1 (2024-09-09)
- The library will now call
trigger_error
instead oferror_log
when a content type has a field called tags, which allows users to easily suppress the warning. The severity was also reduced toE_NOTICE
.
7.1.0 (2024-07-25)
- Support for recursive resolution of Entry links
7.0.2 (2024-02-24)
- Added support for PHP8.3
- Added support for Symfony 7
- Updated header comments
- Re-enabled unit tests for PHP8.2
7.0.1 (2023-01-26)
- Added support for PHP8.2
- Fixed cache handling for queries with default locale, see #320 - thanks @fabianaromagnoli !
- Re-added support for psr/log v1 - see #322
- Updated header comments
- Re-enabled unit tests for PHP8.2
7.0.0 (2022-12-22)
- Breaking change: Dropped support for PHP7
- Breaking change: Updated depdency for contentful/rich-text to 4.0, which has breaking changes - see here.
- Minor docs updates - thanks @mmenozzi !
- Fixed several deprecation warnings.
- CI pipelines slightly reworked
- The unit tests currently segfault on PHP8.2. This is a known PHP bug - see here.
6.4.0 (2022-03-11)
- Support for caching of Client::getEntries() - thanks @mmenozzi !
- Support for psr/cache v2.0 - thanks @kwivix !
- Small CI fixes
- Switched to new CircleCI PHP images
- Due to some interface incompatibility, this version does currently not support psr/cache 3.0 - if you need 3.0, you can stay on 6.3.0 for now. We plan on supporting version 3 again in the future.
6.3.0 (2022-01-19)
Updated Symfony dependencies to allow for Symfony 6 Added support for psr/cache version 3 Added support for a backwards-compatibility breakage check
6.2.0 (2021-10-17)
Support for content tags
Access to localized fields with a non-standard locale (see #270)
Name changed from "SDK" to "Library" to clarify distinction
6.1.0 (2021-03-20)
Support for PHP8
Small changes to the CI due to the migration
6.0.5 (2020-10-19)
withoutMessageLogging option
6.0.4 (2020-09-15)
Update packages Coding standards Fixed a few static code analysis issues
6.0.3 (2020-04-03)
Minor non-breaking changes suggeste by phpstan
6.0.1 (2020-03-13)
Upgraded symfony/console
6.0.0 (2020-03-13)
Added support for PHP 7.4. Removed support for PHP 7.0 & 7.1. Updated dependencies.
5.0.2 (2020-02-24)
- corrected composer dependency for richtext-php
- corrected failing e2e tests
5.0.0 (2020-02-19)
- Bumping major version due to breaking change in rich-text.php
4.1.4 (2020-02-06)
- Cannot fetch large number of independent entries
4.1.3 (2019-12-04)
- Fixed infinite loop when trying to lad a rich text entry that references itself
4.1.2 (2019-11-21)
- Fixed issue with link resolution.
- Addressed cs-fixer syntax issues.
4.1.1 (2019-01-18)
- Sync API now correctly works with deleted entries.
- The SDK now works correctly when using an access token which does not have access to the
master
environment.
4.1.0 (2018-11-28)
- When working with huge datasets (tens of thousands of resources), for instance with custom CLI commands, the default resource pool may have caused the application to use too much memory and crash. Now there are two different resource pools:
Contentful\Delivery\ResourcePool\Standard
, which is a lightweight implemention and only caches space, environment and content types, andContentful\Delivery\ResourcePool\Extended
, which also keeps a reference to entries and assets. The latter class was known asContentful\Delivery\ResourcePool
, which has now been deprecated and will be removed in version 5.0. TheExtended
class is the default one, as it is designed to work with regular PHP requests. In order to use theStandard
pool, you must enable it through theClienOptions
class:As this resource pool provides no caching (and$options = ClientOptions::create() ->withLowMemoryResourcePool(); $client = new Client($token, $spaceId, $environmentId, $options);
include
values are now skipped, for this reason), it might cause the SDK to make more API calls, so its used is discouraged for regular web applications.
4.0.2 (2018-11-09)
- Resolving links from an entry using non-default locale caused the SDK to wrongly assume the
locale=*
. Now this is fixed, and the entry will use either its current locale, if set, or the thelocale=*
if no locales are currently configured.
4.0.1 (2018-11-08)
- Second parameter in
LinkResolver::resolveLinkCollection()
was changed fromstring $locale = null
toarray $parameters = []
.
4.0.0 (2018-11-08)
ATTENTION: This release contains breaking changes. Please take extra care when updating to this version. See the upgrade guide for more.
- Support for PHP 5.6 was dropped. The library now requires PHP 7.0 or higher, and all files use strict types, with scalar type declarations present whenever possible. As PHP 7.0 is also about to reach end of life, we strongly suggest you upgrade to at least PHP 7.1. However, this major release line of the SDK (version 4) will support PHP 7.0 regardless of its status.
- The
Client
constructor signature was changed:public function __construct(string $accessToken, string $spaceId, string $environmentId = 'master', \Contentful\Delivery\ClientOptions $options = null)
. All options that were previously handled through the remaining parameters or the options array can now be set using theClientOptions
object. See the upgrade guide for a more detailed explanation. [BREAKING] - The
Client
object now implementsContentful\Delivery\Client\ClientInterface
. We encourage users to type hint against this interface rather than against the concrete implementation. - The SDK now offers support for rich text. Check the tutorial on the Contentful website for more.
- The SDK now uses version 2 of the
contentful/core
package. We encouraged users to check its changelog and upgrade guide. - The
Query::where()
method used to accept a third parameter, which was used to specify the type of search (for instance with operatorsnear
orlte
). As many users did not know this and appended the operator to the first parameter ofwhere()
, now the third parameter was removed. [BREAKING] - The way system properties are handled was completely changed: previously the SDK used a general
SystemProperties
class with many nullable properties, now every resource type has its own system properties implementation. For instance, the callingContentful\Delivery\Resource\Entry::getSystemProperties()
will now return an instance ofContentful\Delivery\SystemProperties\Entry
, which contains only the necessary methods. [BREAKING] - Method
Entry::has()
when checking against a link by default checks if the link can also be resolved. This behavior can be turned off by setting the third parameter tofalse
. - Logic for resolving links was moved from the
Client
to aLinkResolver
object. The client still provides a convenienceresolveLink()
method which forwards the call. - Method
Client::isPreview()
was renamedClient::isPreviewApi()
. Its opposite,Client::isDeliveryApi()
, was also added. [BREAKING] - Method
Contentful\Delivery\Mapper\BaseMapper::hydrate()
was removed. If using a custom mapper, you can use$this->hydrator->hydrate(object|string $target, array $data)
. [BREAKING] - Interface
CacheItemPoolFactoryInterface
now enforces the return type. [BREAKING] - Class
InstanceRepository
was renamedResourcePool
, and methodClient::getInstanceRepository()
was renamedClient::getResourcePool()
. [BREAKING] - Method
ResourcePool::generateKey()
contained the$api
parameter, which was removed as a resource pool object is supposed to operate within a single API context. [BREAKING] - Third parameter of synchronization manager constructor was changed from
$preview
to$isDeliveryApi
, which is the opposite value. However, users should never build the manager themselves, as they should access it throughClient::getSyncronizationManager()
. [BREAKING]
- Using magic method
Entry::getSomething()
with an invalid field previously resulte in an error being triggered. This behavior was fixed and now a regularInvalidArgumentException
is thrown. [BREAKING]
3.4.0 (2018-08-24)
- The SDK can now use a locally-cached copy of entries and asset. While this will not prevent API calls when using
getEntries
orgetAssets
, it will intercept calls made withgetEntry
andgetAsset
, including those being made when resolving a link from an entry. You can enable this either using the CLI commands with the--cache-content
flag, or passing'cacheContent' => true
to the$options
array in the client constructor (requires'autoWarmup'
to also be set to true).
- Made sure that cache keys are always PSR-6 compliant. Certain PSR-6 implementations have more lax requirements and the SDK took advantage of that, but now all keys only use the character set defined in the official specification.
3.3.0 (2018-06-18)
- Added
getSpaceId
andgetEnvironmentId
to theClient
.
3.2.3 (2018-06-15)
- Fixed incremental build of entries with non-default locale.
3.2.2 (2018-06-06)
- The SDK internally keeps a registry of built resources, and for this reason, partially selecting fields in an entry might have resulted in successive API calls returning the first "incomplete" version. Now entries are continuously updated, so multiple successive API calls will update a resource to include all recently-fetched fields, plus the already existing ones.
- The SDK previously used the hyphen symbol (
-
) as a separator in cache keys. However, some more restrictive PSR-6 implementations do not allow that, so it's been changed to a dot (.
) instead.
3.2.1 (2018-06-01)
Maintenance release.
3.2.0 (2018-04-27)
- Sync API now also works on non-master environments.
- Cache keys for entries and assets sometimes did not contain the locale part, leading to possibly duplicate requests. Now info about locales is prefetched, making sure that cache keys are always correct.
3.1.0 (2018-04-26)
- Entries now have a
has($field)
method (with a magichasX()
equivalent) which returns whether an entry has the given field currently loaded.
- The magic
__call
method now allow for access also using the actual field name, withoutget
prefix (for instance$entry->title()
). This was done to further improve compatibility on edge cases with templating engines such as Twig.
3.0.2 (2018-04-19)
- Cache keys now include space ID and environment ID to better handle possible edge cases.
3.0.1 (2018-04-17)
- Updated the SDK to use a stable version of contentful-core.
3.0.0 (2018-04-16)
ATTENTION: This release contains breaking changes. Please take extra care when updating to this version. See the upgrade guide for more.
- Support for PHP 5.5 was dropped. PHP 5.5 has reached EOL in July 2016, so we highly discourage anyone from keep using it for multiple reasons, including possible security concerns. The SDK now requires at least PHP 5.6; however, PHP 5.6 is not actively supported and currently only security fixes are provided. Because of this, we strongly encourage everybody to upgrade to a version in the PHP 7 branch, ideally 7.1 or 7.2, which are actively supported. Many other popular frameworks and tools already require a version in the PHP 7 branch: Symfony 4 requires 7.1, Laravel 5.5 requires 7.0, Laravel 5.6 requires 7.1, PHPUnit 6 requires 7.0, PHPUnit 7 requires 7.1, etc. Because of the clear convergence of the PHP ecosystem towards this upgrade, and the availability of tools that allow you to easily manage your PHP version (such as Docker), we can't guarantee that the next major version of this SDK (version 4) will still keep compatibility with PHP 5.6. However, compatibility is guaranteed for the whole lifecycle of the PHP Contentful Delivery SDK version 3, and important bugfixes (including security-related ones) will be backported once version 4 will be released.
- The SDK now supports space environments.
- The
ResourceBuilder
now supports custom data type matchers so users can create their own custom resource classes. - All resource classes now extend
Contentful\Delivery\Resource\BaseResource
, which implementsContentful\Core\Resource\ResourceInterface
. You can use these two classes for type hinting. - Entry objects now support accessing fields through virtual properties with
__get
($entry->title
) and using theArrayAccess
interface ($field['title']
).
- There was an issue when adding a new field to a Contentful content type without purging the SDK cache, with the SDK not knowing how to build the field. Now it will create a temporary fake field of type
Unknown
, and it will also trigger a silenced error of levelE_USER_WARNING
(so users can implement some custom logic for handling the issue, without causing any problems to the actual execution). When retrieving the unknown field, it will be returned as it was fetched from the API, so no conversion will be made. This means that dates will be returned as strings, links will be returned as simple arrays, etc. This solution was implemented to prevent the SDK from crashing during those (hopefully) brief moments where the cache is out of sync with Contentful, and it should not be relied upon for actually handling the fields in a proper way.
- The cache system has been rewritten to be made PSR-6 compatible (thanks @magnusnordlander). [BREAKING]
DynamicEntry
,Asset
,ContentType
,ContentTypeField
,Space
, andLocale
,DeletedAsset
, 'DeletedEntry', andDeletedContentType
classes have been moved to a different namespace. Please check the the upgrade guide for more details. [BREAKING]- All parts of the SDK that were not in the
Contentful\Delivery
namespace have been moved to a separate package called contentful-core.php. - The option in the client constructor for specifying a custom URI is now called
baseUri
instead ofuriOverride
, to be more consistent with the one used in Guzzle. [BREAKING] - The SDK no longer used a custom logger. It now supports any PSR-3 compatible logging implementation for permanent storage, but easy access to a log of current API requests is provides through
Client::getMessages()
, which returns an array ofContentful\Core\Api\Message
. [BREAKING] - The SDK now keeps a registry of all resources that are currently managed, called
Contentful\Delivery\InstanceRepository
. This class also wraps the PSR-6 cache pool. Client::reviveJson()
is now calledClient::parseJson()
to better reflect its meaning.- The Sync API currently only works with the
master
environment. When trying to perform sync-related operations on a client which is configured with any other environment, a\RuntimeException
will be thrown. - Previously, entry objects would try to use the locale fallback chain even in situations where this might lead to results that differ from those that would be normally returned from the Delivery (or Preview) API. For this reason, when requesting an entry using any other locale than
locale=*
, the locale fallback chain will not be used. The Sync API defaults to using all locales, so it's not affected. [BREAKING]
Contentful\Delivery\EntryInterface
no longer exists. UseContentful\Delivery\Resource\Entry
for type hinting. [BREAKING]Contentful\JsonHelper
was deprecated in 2.2, and has now been removed. [BREAKING]Contentful\DateHelper
was deprecated in 2.2, and has now been removed. [BREAKING]Contentful\File\UploadFile
was deprecated in 2.1, and has now been removed. UseContentful\Core\File\RemoteUploadFile
instead. [BREAKING]- Resource classes have now a protected constructor, because they are not supposed to be instantiated without using the
ResourceBuilder
. [BREAKING] Asset
,ContentType
,Entry
, andDeletedResource
classes previously provided shortcut methods for accessing system properties such as revision, createdAt, etc. These shortcut methods have been removed from the main resource, but they're still accessible through aSystemProperties
object. See the upgrade guide for more. [BREAKING]
2.4.1 (2018-01-25)
- The
Contentful\Synchronization\Manager
class now provides a convenience method calledsync($token = null, Query $query = null)
which transparently handles a full sync, instead of having to manually callstartSync
andcontinueSync
. The method returns instances ofContentful\Synchronization\Result
wrapped in a\Generator
object. - Added missing exception class
Contentful\Exception\BadRequestException
.
2.4.0 (2018-01-11)
- The
Contentful\Delivery\Query
class now haslinksToEntry('<entry_id>')
andlinksToAsset('<entry_id>')
methods. For users on older versions of the SDK, the same operators can be emulated by using$query->where('links_to_entry', '<entry_id>')
and$query->where('links_to_asset', '<asset_id>')
.DynamicEntry
also provides a shortcut in the form$entry->getReferences()
.
- The SDK now implements a strict coding standard based on the one found on the Symfony Demo. The
@Symfony:risky
ruleset is currently implemented, but this could be subject to change in the event of possible incompatibilities. The style check is a mandatory part of CI. - Methods are no longer marked as
@api
or@internal
. If a method is public, it's assumed to be part of the API surface of the SDK, and thus any breaking change to that would require a new major version.
2.3.0 (2017-12-01)
- Dependencies to
symfony/console
andsymfony/filesystem
now also allow version~4.0
.
2.2.0 (2017-09-26)
DateHelper::formatForJson()
is now deprecated and will be removed in version 3. UseContentful\format_date_for_json()
instead.JsonHelper::encode()
andJsonHelper::decode()
are now deprecated and will be removed in version 3. UseGuzzleHttp\json_encode()
andGuzzleHttp\json_decode()
instead.
LogEntry
now modifies the exception stack trace (if present) to prevent problems during serialization.
2.1.0 (2017-07-14)
- Allow the exception map in
Client
to be overridden. This is done in preparation of the upcoming CMA SDK. - The third parameter
$options
of theClient::request()
method now accepts an optional value with keybaseUri
. This is in preparation for the CMA SDK. - Revamped the reference documentation to be based on Sami and to include previous versions of the SDK.
LocalUploadFile
now handles asset files which have been uploaded toupload.contentful.com
but have yet to be processed. This fixes a possible edge case, and it's also done in preparation for the upcoming CMA SDK.Contentful\Client
now includes agetLogger
method, for easy access to the logger currently in use.
- Slight fixes to error messages in exceptions thrown in the
ResourceBuilder
. - Adds a missing exception message in
SynchronizationManager::continueSync()
.
2.0.1 (2017-06-16)
ResourceBuilder
now correctly handles locale when building referenced assets.Asset::getFile
now uses fallback chain logic to determine the locale to use.
2.0.0 (2017-06-13)
ATTENTION: This release contains breaking changes. Please take extra care when updating to this version.
Link
implements theJsonSerializable
interface. This is done in preparation for the upcoming CMA SDK.UploadFile
class now manages files which aren't yet processed (for Preview API) [BREAKING].Contentful\Delivery\Asset::getFile
now returnsContentful\Delivery\File\FileInterface
instead of one ofFile|ImageFile
. If you were type hinting on either one of those, please now use the interface or addUploadFile
to the possible types.- Exceptions thrown because of an API error now extend
ApiException
. This class gives access to some additional data like, the request, response and request ID. - Extended
Client
to support a future CMA SDK.
- Retrieving a list of entries that contained multiple loops creates too many objects. [BREAKING] (#105) The new behavior is, that any entry that appears multiple times in the graph of the response will be the same instance.
- The
contentful
script used to warm up/clear the cache was not marked as a binary incomposer.json
and thus not published tovendor/bin
. - In console commands
<info>
can't be used as part of an Exception message. (#129) - Assets that are part of includes would not be resolved and always fetched again.
Client::request
ignored the timer returned inLoggerInterface::getTimer
when timing requests.
- Moved file classes to a sub-namespace
Contentful\File
[BREAKING].Contentful\File
toContentful\File\File
Contentful\ImageFile
toContentful\File\ImageFile
Contentful\ImageOptions
toContentful\File\ImageOptions
1.2.0 (2017-05-16)
- Implemented
ResourceArray::getItems
to allow access to the values of aResourceArray
as an actual PHP array. - Send the new
X-Contentful-User-Agent
header.
1.1.0 (2017-05-11)
- Implemented
DeletedEntry::getContentType()
to be used with webhooks. (#101)
- The minimum required version of
guzzlehttp/psr7
is now 1.4.
- Retrieving assets with the Preview API fails if no file is set. (#99)
- When lazy-loading a linked entry, it would always be fetched in the default locale. (#109)
1.0.0 (2017-04-26)
- Content in disabled fields can now be read.
0.8.1-beta (2017-04-11)
- The caching of resolved links does not work for an array of links.
0.8.0-beta (2017-04-10)
ATTENTION: This release contains breaking changes. Please take extra care when updating to this version.
- Renamed a few classes to move them outside the Delivery namespace. [BREAKING]
Contentful\Delivery\Link
toContentful\Link
Contentful\Delivery\ImageOptions
toContentful\ImageOptions
Contentful\Delivery\File
toContentful\File
Contentful\Delivery\ImageFile
toContentful\ImageFile
- Renamed
ResourceNotFoundException
toNotFoundException
to match the names the API uses. [BREAKING] - Turned
Contentful\Query
into an abstract class to promote separation between CDA and CMA SDKs. [BREAKING]
- Removed all get* methods except
getQueryData()
andgetQueryString()
from the various query classes. [BREAKING]
- The
FilesystemCache
would try to read cached content types from the wrong file name. CacheWarmer
wrote incorrect data for content types.- Retrieving a cached content type would cause the maximum function nesting level to be exceeded.
- Correctly set the
Accept
header for API versioning. Previously theContent-Type
header was set instead. - Serializing a
LogEntry
would fail if no response has been set.
0.7.0-beta (2017-04-06)
ATTENTION: This release contains breaking changes. Please take extra care when updating to this version.
- Added support for the
webp
format in the Images API. - Introduced
RateLimitExceededException
,InvalidQueryException
andAccessTokenInvalidException
for more specific error handling. [BREAKING] - Allow injecting a custom Guzzle instance into
Client
. - Allow fetching content in a single locale by adding the locale code to the query. [BREAKING]
MIGRATION: To retain the old behavior set the default locale to
'*''
when creating the client. This could look like:new Client($token, $spaceID, false, null, ['defaultLocale => '*'])
- Allow setting the locale in which you work when creating the client.
- Allow overriding the URI used to connect with the Contentful API.
- The
select
operator can now be specified on queries. Thanks @Haehnchen. - Support for the
all
operator and passing arrays as$value
inQuery::where()
. - Support for ordering by multiple fields.
- The space metadata and the content types can now be cached with a CLI command.
- Support for caching the Space and Content Types. The cache has to be manually warmed and cleared.
- Changed the behavior of getting an array of links to not throw an exception when one of them has been deleted from the space. (#19)
- Removed the caching of
Asset
andEntry
instances. [BREAKING] - Changed the internal data format from object to array. This should make no observable difference to the public API.
- Moved all Exception classes to their own namespace. [BREAKING]
- Changed the signature of the constructor of
Contentful\Delivery\Client
. Several options are now in an options array. [BREAKING] - The Sync API can now also be used with the Preview API. Only initial syncs are supported.
- Dist zip files no longer include the tests directory. If you need them use
composer install --prefer-source
.
- Dropped
BearerToken
to make it easier to inject custom Guzzle instances. Thanks @Haehnchen. [BREAKING] - The class generator has been removed. It was unusable.
- Assets that have no title would throw an uncaught exception.
- Handling of missing values for a locale in Assets. Solved by implementing fallback locales for Assets too. (#38)
- Fields that have the literal value
null
are now treated like they don't exist. Previously they might have causes a fatal error. Note: This does not 100% match the behaviour of the Contentful API. - The error message for
Query::setLimit
was incorrect. - Allow accessing fields where the first letter of the ID is capitalized. (#68)
0.6.5-beta (2016-09-10)
- Added gzip compression for API requests.
- Raised the minimum Guzzle version to 6.2.1. This version addressed the HTTP_PROXY security vulnerability (CVE-2016-5385).
- Trying to retrieve fields that end with "Id" fails. #9
0.6.4-beta (2016-03-03)
- Made LogEntry implement Serializable.
- Send the correct Content-Type header for API versioning.
0.6.3-beta (2016-03-02)
- Implemented missing functionality of the Contentful Images API in ImageOptions.
- Added the missing method LogEntry::getResponse
- Added LogEntry::isError
- Logged requests were always shown as belonging to the Delivery API, even when the Preview API was used.
- Fields not present in an Entry would lead to an error.
- The Synchronization Manager's method
startSync
was type hinted to the wrong Query class. - API responses were not correctly logged.
0.6.2-beta (2016-02-22)
- Compatibility with Symfony 3.
- The ability to log information about requests made against the Contentful API.
- Use PSR-7 internally.
- Default headers were never actually sent
0.6.1-beta (2016-01-19)
- Send a User-Agent header with API requests.
- When GitHub is generating archives, are few files with metadata are excluded.
- Calling the get*Id Method on a field that is not a link or an array of links did not cause an error. (#2)
- Accessing a non-localized field would fail with and throw a PHP notice.
0.6.0-beta (2015-12-11)
Initial release