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. The API-First Framework Gets New Superpowers

  2. About me ✔ API Platform creator ✔ Les-Tilleuls.coop founder Kévin

    Dunglas @dunglas dunglas.fr
  3. Improved Developer eXperience 01 02 03 04 Re-Engineered Design Standalone

    Client Tools New Roadmap
  4. But… Where Is API Platform 3?!

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

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

    Write docs and changelogs ✔ Write blog posts ✔ Tag 10th of packages ✔ Update the distribution
  8. None
  9. Let’s Celebrate API Platform Release Party 6pm @ Les Sales

    Mômes
  10. None
  11. 01 - Re-Engineered Design

  12. 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
  13. 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 😻
  14. 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
  15. 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
  16. 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
  17. Interesting Standards Uniform Resource Identifiers (URI): ✔ ID system for

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

    be substituted ✔ https:/ /example.com/organizations/{oID} /users/{uID} URI Template
  19. Resource-Oriented Framework DEFINE THE RESOURCES TO EXPOSE

  20. 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
  21. Resource-Oriented Framework ✔ Provides the infrastructure layer of your API

    ✔ Serializes resources representations from PHP objects ✔ Transforms resources representations in PHP objects
  22. Define The Resources Define your resources

  23. 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
  24. 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)
  25. Improved Metadata

  26. None
  27. Resource-Oriented Framework PLUG YOUR BUSINESS LOGIC

  28. Hook Your Domain

  29. State Provider

  30. State Processor

  31. None
  32. Still Natively Supported ✔ Doctrine ORM - Postgres, SQLite, MySQL,

    MariaDB, Oracle, DB2, SQL Server ✔ Doctrine MongoDB ODM ✔ ElasticSearch (read-only) Use them (only) when needed!
  33. 02 - Improved Developer eXperience

  34. 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…)
  35. New: Native Xdebug Support $ XDEBUG_MODE=debug docker compose up

  36. New: Better Next Integration ✔ Brand new Dockerfile ✔ pnpm

    instead of yarn ✔ Output File Tracing for prod ✔ Faster builds ✔ Slimmer image
  37. 03 - Standalone Client Tools

  38. 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
  39. API Platform Create Client ✔ OpenAPI support, works with any

    API ✔ Improved skeletons - TypeScript - Mercure - Modern libs $ pnpm create \ @api-platform/client
  40. 04 - New Roadmap

  41. 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
  42. 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 ✔ 🔁
  43. None
  44. Thank you! ENJOY THE CONFERENCE! @dunglas dunglas;fr Questions during the

    Q&A session!