Upgrade to Pro — share decks privately, control downloads, hide ads and more …

API Platform 3

API Platform 3

What's new in API Platform 3?

Kévin Dunglas

September 15, 2022
Tweet

More Decks by Kévin Dunglas

Other Decks in Programming

Transcript

  1. Antoine Bluchet aka soyuka ✔ API Platform 3 lead ✔

    Long-time Core Team member ✔ Famous FOSS contributor ◦ pm2 maintainer ◦ JS, PHP, Go…
  2. Let’s Release It Now! ✔ Test, fix, test 🔁 ✔

    Write docs and changelogs ✔ Write blog posts ✔ Tag 10th of packages ✔ Update the distribution
  3. 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
  4. 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 😻
  5. Opportunities for v3 ✔ Fix design issues ✔ Leverage new

    features of our stack ◦ Improved PHP attributes and types ◦ Symfony, Docker, Next.js, Caddy… ✔ Rely even more on standards ◦ RDF ◦ OpenAPI ✔ Reduce maintenance burden ◦ Remove legacy code
  6. 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
  7. 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
  8. Interesting Standards Uniform Resource Identifiers (URI): ✔ ID system for

    web resources ✔ https:/ /example.com/organizations/22/us ers/42 URI
  9. Interesting Standards URI Template: ✔ URI that includes parameters to

    be substituted ✔ https:/ /example.com/organizations/{oID} /users/{uID} URI Template
  10. 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
  11. Resource-Oriented Framework ✔ Provides the infrastructure layer of your API

    ✔ Serializes resources representations from PHP objects ✔ Transforms resources representations in PHP objects
  12. 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
  13. 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)
  14. Still Natively Supported ✔ Doctrine ORM - Postgres, SQLite, MySQL,

    MariaDB, Oracle, DB2, SQL Server ✔ Doctrine MongoDB ODM ✔ ElasticSearch (read-only) Use them (only) when needed!
  15. 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…)
  16. New: Better Next Integration ✔ Brand new Dockerfile ✔ pnpm

    instead of yarn ✔ Output File Tracing for prod ✔ Faster builds ✔ Slimmer image
  17. 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
  18. API Platform Create Client ✔ OpenAPI support, works with any

    API ✔ Improved skeletons - TypeScript - Mercure - Modern libs $ pnpm create \ @api-platform/client
  19. 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
  20. 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 ✔ 🔁