Skip to content

Latest commit

 

History

History
67 lines (52 loc) · 4.65 KB

AGENTS.md

File metadata and controls

67 lines (52 loc) · 4.65 KB

Agent Guide

Read this file first. It tells you where to find context in this repo.

Quick Reference

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/

Sharp Edges & Invariants

  • Namespace is Contentful\Delivery\* — all public types live under this namespace. Do not add classes to Contentful\Core\* or any other namespace; cross-SDK concerns belong in contentful/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 multiple Client objects.
  • 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).
  • ResourcePool is the identity map — do not instantiate domain resources directly outside of mappers. Always go through ResourceBuilder::build() so the pool is correctly populated and duplicates are deduplicated.
  • php-vcr cassettes 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 to null when serializing to cache.
  • phpstan level 5 must pass. There is a known warning about LocalizedResource::$sys undefined 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 -v before committing. CI will fail on unfixed style. The warning about running on a newer PHP version than the minimum supported is cosmetic and expected.

Key Conventions

  • 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: master is the default branch. Feature branches are short-lived; PRs merge to master. No separate main branch.
  • Test location: tests/ mirrors src/ structure. Integration test cassettes live under tests/ 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.

Integration Points

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 base
  • contentful/rich-text ^4.0 — rich-text field parsing

Downstream (consumes this repo):

  • contentful/contentful-laravel — Laravel service provider
  • contentful/ContentfulBundle — Symfony bundle
  • Any PHP application fetching Contentful CDA content

Build & Quality

# 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