Read this file first. It tells you where to find context in this repo.
| What you need | Where to look |
|---|---|
| How this repo is structured | ARCHITECTURE.md |
| How to build/test/run | CONTRIBUTING.md |
| Why decisions were made | docs/ADRs/ |
| What this repo does | README.md |
| PR review rules | .bito/guidelines/ |
| Active specs/work | docs/specs/ |
- Namespace is
Contentful\Delivery\*— all public types live under this namespace. Do not add classes toContentful\Core\*or any other namespace; cross-SDK concerns belong incontentful/core. - One
Client= one space + one environment. The space ID and environment ID are constructor arguments and immutable. There is no "multi-space client" — callers must instantiate multipleClientobjects. MAX_DEPTH = 20— link resolution is recursive. Exceeding depth 20 throws. Do not raise this limit without understanding the memory implications on large entry graphs.- Backward compatibility is enforced by CI (
roave/backward-compatibility-check). Any removal or signature change to a public API method is a breaking change requiring a major version bump. Even dropping a PHP version is a breaking change (major bump required). ResourcePoolis the identity map — do not instantiate domain resources directly outside of mappers. Always go throughResourceBuilder::build()so the pool is correctly populated and duplicates are deduplicated.php-vcrcassettes are fragile — the Contentful space used to record existing integration test cassettes no longer exists. Do not delete cassettes, but do not record new cassettes against the old space. New integration tests should mock at the HTTP layer directly or use a live test space. See ADR-0005.- PSR-6 cache keys are generated by the resource pool — do not construct or hard-code cache keys. Always call
ResourcePool::generateKey(). - Locale wildcard
'*'is used internally when a resource is fetched without an explicit locale (meaning "all locales"). Never strip or override the locale tonullwhen serializing to cache. phpstanlevel 5 must pass. There is a known warning aboutLocalizedResource::$sysundefined property on PHP 8.1 — it is intentionally left unresolved (fixing it breaks backward compat with PHP ≤ 8.1). Do not suppress it globally; see ADR-0004.- php-cs-fixer auto-fixes style — always run
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -vbefore committing. CI will fail on unfixed style. The warning about running on a newer PHP version than the minimum supported is cosmetic and expected.
- Commit format: no enforced Conventional Commits hook, but the team uses
feat:,fix:,chore:,docs:,refactor:prefixes by convention (see recent git history). - Branch strategy:
masteris the default branch. Feature branches are short-lived; PRs merge tomaster. No separatemainbranch. - Test location:
tests/mirrorssrc/structure. Integration test cassettes live undertests/alongside the test classes. - PHP minimum: PHP ^8.0 (see
composer.json). Do not use syntax or functions unavailable in PHP 8.0. - Autoload:
Contentful\Delivery\→src/,Contentful\Tests\Delivery\→tests/(PSR-4). - Release: Semver via manual PR + GitHub Release + Packagist webhook. All releases go through a PR with CI passing. See the release workflow documented in CONTRIBUTING.md for the full checklist.
Upstream (this repo consumes):
- Contentful CDA (
https://cdn.contentful.com) — primary read-only content API - Contentful CPA (
https://preview.contentful.com) — preview (unpublished) content contentful/core^4.0 — shared HTTP client and resource builder basecontentful/rich-text^4.0 — rich-text field parsing
Downstream (consumes this repo):
contentful/contentful-laravel— Laravel service providercontentful/ContentfulBundle— Symfony bundle- Any PHP application fetching Contentful CDA content
# Open in dev container first (Docker required)
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash
# Quick verification loop (inside container)
composer test-quick-fail
# Full suite
composer test
composer run lint-static-analysis
composer run test-for-bc-breaks