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

Rapid REST API Development with Symfony

Rapid REST API Development with Symfony

Combining multiple tools from Symfony community to create a REST API in minutes.


Pawel Jedrzejewski

October 31, 2015


  1. None
  2. Paweł Jędrzejewski I really like Open Source I created Sylius

    I co-founded Lakion I help organize PHPers Łódź
  3. @pjedrzejewski What does it mean to be rapid? ?

  4. @pjedrzejewski rapid - [rap-id] - adjec7ve Moving, acGng, or occurring

    with great speed.
  5. @pjedrzejewski Every startup needs an MVP.

  6. *Minimum Viable Product

  7. @pjedrzejewski Many of them are unpleasantly surprised with the fact

    that they need to maintain it aLer going live.
  8. When you need to do a significant change in your

  9. None
  10. @pjedrzejewski Time Value delivered This is not rapid.

  11. @pjedrzejewski Time Value delivered This is rapid.

  12. @pjedrzejewski Long-term flexibility over short-term graGficaGon from saGsfying the management

    or the investors.
  13. @pjedrzejewski What is an API? ?

  14. @pjedrzejewski ApplicaGon Programming Interface

  15. @pjedrzejewski SoLware-to-SoLware interfaces

  16. Machines talking to machines… You have been warned.

  17. Why do we need APIs? @pjedrzejewski User Your app Amazon

    UI API
  18. Why do we need APIs? @pjedrzejewski • Sharing data and

    avoiding duplicaGon • Decoupling funcGonality (SRP, SeparaGon of Concerns etc.) • Allowing other people to consume our service
  19. @pjedrzejewski What kind of APIs are out there? ?

  20. @pjedrzejewski GET /createNewChargeV2 CrappyAPI „I\ don\’t\ want\ 2\ do\ this”!UserID:1!250!USD!

    test@example.com# With the following data sent:
  21. @pjedrzejewski POST / HTTP/1.1 Host: xyz.com Content-Type: applicaGon/soap+xml; charset=uo-8 <?xml

    version=„1.0” ?> <soap:Envelope …> <m:GetUserDetails> <m:UserID>41</m:UserID> </m:GetUserDetails> </soap:Envelope> SOAP
  22. @pjedrzejewski GET /users/41 HTTP/1.1 Host: xyz.com Accept: applicaGon/json REST

  23. @pjedrzejewski That being said, „REST or SOAP?” is a wrong

  24. @pjedrzejewski REST is not a protocol. It is an architectural

  25. REST API Principles @pjedrzejewski Client-server architecture Stateless Cacheable Based on

    standards (HTTP, URL, XML, JSON) Independent from the plaoorm and language
  26. The Richardson Maturity Model @pjedrzejewski Level 0: Swamp of POX

    Level 1: Resources Level 2: HTTP Verbs Level 3: Hypermedia Controls
  27. Install LIONFRAME $ composer create-project lakion/lionframe @pjedrzejewski @pjedrzejewski

  28. @pjedrzejewski DEMO

  29. How?

  30. @pjedrzejewski @pjedrzejewski

  31. @pjedrzejewski @pjedrzejewski

  32. Bundles, Bundles, Bundles @pjedrzejewski FOSRestBundle JMSSerializerBundle BazingaHateoasBundle SyliusResourceBundle

  33. @pjedrzejewski It can be plugged into an exisGng Symfony app.

  34. Use case: Sylius E-Commerce API Sylius API Mobile API @pjedrzejewski

    User API
  35. Extras! @pjedrzejewski FOSOAuthServerBundle FOSHzpCacheBundle SyliusRbacBundle

  36. lakion.com/lionframe

  37. DOCS.sylius.org - Sylius Resource Bundle

  38. @pjedrzejewski @Sylius @Lakion pjedrzejewski.com sylius.org lakion.com THANK YOU!