API Platform Core Values ✔ Easy to use… - Rapid Application Development ✔ …but suitable for advanced use cases - DDD, Clean Architecture, microservices… ✔ Batteries included ✔ Fast, cheap, and green ✔ Standards-compliant
Pain Points With v2 ✔ “Subresources” (e.g. /organization/1/users/22) - Read-only - hard to customize ✓ Having small resources linked together instead of big resources improve performance and cache dynamics, cf. my Edge Side APIs presentation ✔ Hooking custom logic - possible but not trivial, not well understood ✓ DDD, Clean Architecture and custom persistence should be intuitive and easy ✔ Configuration - Verbose and hard to read ✓ Leverage PHP 8 attributes 😻
Back to The Basics: The Web Architecture ✔ Webapps expose a network of resources ✔ Resources: - Any information that can be named - Valid resources: a thing, a temporary service, a collection of resources ✔ Resources have representations: - Ex: JSON-LD, JPEG, CSV… - The same resource can have multiple representations REST
Interesting Standards Resource Description Format (RDF) ✔ Data model for web resources ✔ Various serialization formats: JSON-LD, Turtle, XML-RDF, RDFa… ✔ Classes, properties, links, type system… RDF
Interesting Standards URI Template: ✔ URI that includes parameters to be substituted ✔ https:/ /example.com/organizations/{oID} /users/{uID} URI Template
PHP As an API Specification Language ✔ Describe the public data model exposed by the API ✔ Leverage the expressivity of PHP: - Types, visibility, relations, attributes… ✔ Resource objects are DTOs
Resource-Oriented Framework ✔ Provides the infrastructure layer of your API ✔ Serializes resources representations from PHP objects ✔ Transforms resources representations in PHP objects
New: Import Your Data Model ✔ Create or use an existing RDF vocabulary… ✔ … or an OpenAPI Definition ✔ Run Schema Generator 5 to generate the PHP classes $ bin/schema generate \ src/ model-definition.yaml Design your API with Stoplight
New: Improved Metadata ✔ PHP 8.1’s nested attributes ✔ Based on URI templates - Full control on the URL - Read+Write subresources - “Subresources” aren’t special anymore ✔ RDF & OpenAPI annotations (eg. types)
New: Better Onboarding $ docker compose up ✔ Buildkit, Docker Compose v2 ✔ Faster and less frequent builds ✔ Faster on Mac and Windows ✔ Cleaner Caddy and PHP config ✔ Still prod-ready (Kubernetes…)
API Platform Admin ✔ OpenAPI support, works with any API ✔ Real-time updates with Mercure (if enabled on your API) ✔ Improved performance ✔ Better Schema.org compatibility ✔ Uses React Admin 4.3
API Platform Create Client ✔ OpenAPI support, works with any API ✔ Improved skeletons - TypeScript - Mercure - Modern libs $ pnpm create \ @api-platform/client
New Roadmap ✔ Major version every 2 years - Deprecated code removal - Drop support for non-current Symfony ✔ Minor version every 6 months ✔ Upgrade path: last minor = new major + backward compatibility
New Roadmap ✔ September 2022: API Platform 3 and 2.6 ✔ November 2023: Symfony 7.0 ○ API Platform 3.2: compat wit Symfony 6 and 7 ✔ September 2024: API Platform 4.0 & 3.4 ○ API Platform 4.0: Symfony 7 only ✔ 🔁