api-platform/core
PHP framework for building hypermedia REST and GraphQL APIs from your models
Repository Health
Technical Analysis
API Platform Core is the server component of API Platform, a PHP framework for building fully-featured hypermedia REST and GraphQL APIs in minutes. By annotating your data classes as API resources, it generates CRUD endpoints, negotiates formats, and exposes machine-readable documentation without hand-writing controllers.
It integrates natively with Symfony and Laravel and supports a wide range of standards and formats out of the box — OpenAPI/Swagger, JSON-LD with Hydra, JSON:API, HAL, and GraphQL — along with pagination, filtering, validation, and content negotiation, making it one of the most complete API frameworks in the PHP ecosystem.
What You Get
- Automatic REST and GraphQL endpoints generated from resource classes
- Built-in OpenAPI/Swagger, JSON-LD, Hydra, JSON:API, and HAL support
- A state provider/processor pipeline for reads and writes
- Pagination, filtering, sorting, and validation out of the box
- Native integration with both Symfony and Laravel applications
Common Use Cases
- Exposing a domain model as a standards-compliant REST API
- Adding a GraphQL API on top of existing PHP entities
- Generating live, machine-readable API documentation automatically
- Building a hypermedia API with content negotiation and format support
Under The Hood
Architecture — API Platform Core is built around a metadata-driven resource system: classes are declared as API resources via attributes, and a Metadata layer (src/Metadata) compiles resource and operation definitions that drive everything else. Requests flow through a State layer (src/State) of providers and processors that read and persist data, with Doctrine and Elasticsearch integrations supplying persistence, while format-specific modules (Hydra, JsonLd, JsonApi, Hal, OpenApi, GraphQl, Problem) handle serialization, documentation, and content negotiation. Symfony (src/Symfony, a bundle) and Laravel (src/Laravel) integration layers wire the framework into each host, and a Serializer layer bridges to normalizers. Tech Stack — Modern PHP built primarily on Symfony components (serializer, validator, routing) with optional Laravel support, Doctrine ORM/ODM for persistence, webonyx/graphql-php for GraphQL, and Elasticsearch; quality is enforced with PHPUnit, PHPStan (phpstan.neon.dist with baselines), and Codecov under CI. Code Quality — A large, mature codebase (thousands of commits, very active maintenance) with an extensive tests/ suite mirroring src, static analysis baselines, and clear module boundaries per concern; the presence of an AGENTS.md and structured docs/ signals disciplined contribution practices. API Design — For consumers the primary interface is declarative: annotate an entity with #[ApiResource] and configure operations, and the framework does the rest, which makes simple APIs extremely fast to build; deeper customization through custom state providers/processors, filters, and normalizers is powerful but introduces a meaningful learning curve around the metadata and state abstractions.