API Platform: Serious RESTful APIs

2:54:11

What you'll be learning

API Platform is crushing the scene these days. And it's easy to see why! Built on top of Symfony, API Platform enables you to build a rich, JSON-LD-powered, hypermedia API... pretty much instantly! In this tutorial, we'll build a real app and leverage these tools:

  • Setting up API Platform in a Symfony app
  • Swagger, OpenAPI & JSON-LD+Hydra: what they are and why they're awesome
  • Creating ApiResources
  • Customizing the operations
  • IRIs & how to control them
  • Resource relations
  • Embedded resources & Subresources
  • Filters
  • Pagination
  • Validation
  • The serializer & controlling input/output fields

Your Guides
Niels van der Molen Ryan Weaver

Buy Access

Questions? Conversation?

  • 2019-08-13 Diego Aguiar

    Hey Sébastien JEAN

    We are actively releasing a new course about Api Platform + Symfony + Vue.js. I know it's not ReactJS but its internals are very similar
    https://symfonycasts.com/sc...

    Cheers!

  • 2019-08-13 Sébastien JEAN

    Hey,
    Are you planning to release a course with API Platform and ReactJS ?

  • 2019-07-03 weaverryan

    Wow, nice work Kiss Dávid! Thanks for sharing - I was interested if this was ultimately going to work - very cool.

  • 2019-07-03 Kiss Dávid

    Thank you for your answer and sorry for my late reaction, i was lost in space. :D
    During this time, i found a solution for my 'challenge :)' The following two posts helped me to handle the custom URLs: post 1 and Post 2. I had to modify some methods to handle the account id dynamically. In the close future i will add URL or IRI generator class(es) to handle the sub-sub URLs (similar to sub-sub-resources). Besides in my case i had to add a custom data provider, due to the usage of the account id. Fortunately i could add the APIP-way pagination, filtering and searching support to custom data providers. (The ODM way wasn't clear at the first look. :) )

  • 2019-06-26 weaverryan

    Hey Vladimir Leitenberger!

    Interesting idea... it's not currently on my list to cover for the next "security" tutorial... because they're kinda two separate things. But, I've upvoted this in our internal idea list - it's something that we *may* cover, but I don't have any timing yet.

    Cheers!

  • 2019-06-20 weaverryan

    Hey Kiss Dávid!

    Thanks for the nice words! And yes, we'll get to the custom controller stuff... API stuff is such a huge topic - we need a few parts :).

    About your questions... I don't think there's good news here. As you maybe already saw, this isn't supported currently (https://github.com/api-plat....... which means you'll need to add this stuff manually. That's not a total loss... you'll still be able to rely on API Platform's serialization/deserialization stuff, validation, security, etc. There *may* be some more clever way to make this all work.. but I haven't played with it yet. For example, in "theory" (big quotes... as I've tried none of this!), you could do this by filling in a few pieces. Basically, the goal would be customize things so that Store could be a normal ApiResource, which just has this custom URL:

    1) customize the URL of each operation in Store (I think this needs to be done for each individual operation)
    2) To make the above work, I think you will need a getAccountId() method inside Store, so that API platform knows what to use for the account_id part in the IRI when generating it.
    3) You may also need a custom data provider so that you can use the account_id in a custom query to return all of the stores.

    And... probably there are 5 other small details - I really don't know, unfortunately. But, for me, it would be worth trying to see if you can get the above to work, as it would ultimately allow you to use ApiPlatform in a "normal" way, instead of needing to make a lot of custom endpoints.

    Let me know what you find out!

    Cheers!

  • 2019-06-19 weaverryan

    Yep! Sorry about that! The tutorials tend to evolve as we write them :). In this case, there was too much to cover in part one - but it's still planned for the future.

    Cheers!

  • 2019-06-19 Kiss Dávid

    Hey weaverryan !
    First of all i'd like to thanks your tutorials, i really like those and are really helpful.
    I agree with Gabriel's post, APIP is really good, but now i have a problem with custom URLs. My goal is to use a url scheme, where the first 2 parameters reference to account and account id, and most of the URLs contain it. The following parameters are store, products and so on. e.g.: /account/account_id/stores or /account/account_id/store/store_id/products...
    The sub-resources would be good, but unfortunately it supports GET operation only. I try to find a proper solution for my problem, but i haven't found it yet. I hope you can give me some starter points how i can manage this URL structure.
    Thanks in advance!

  • 2019-06-19 Victor Bocharsky

    Hey Br!

    Good news for you - we're going to cover GraphQL topic as well, but we will do it in further episodes. This is a big topic and we wanted to make a separate episode for this.

    Cheers!

  • 2019-06-18 Br

    Why did you change the name from "API Platform: Serious RESTful & GraphQL API" to "API Platform: Serious RESTful APIs"? :(
    I was waiting for the GraphQL part the most.

  • 2019-06-17 Gabriel Mustiere

    Yes, I know about this feature, Kevin talked about it in a twitter conversation -> https://twitter.com/MrConsp..., it's still a little obscure and not very intuitive to implement, "just for a simple endpoint", Thks

  • 2019-06-17 weaverryan

    Hey Gabriel Mustiere!

    I agree 💯! We will cover it, but not in this tutorial. And yes, the docs are a bit confusing on this topic, as the "best" way to do it is kinda changing... I'm talking to Kevin about this. So, we will get there - but not until probably part 3 (part 2 will all be about security). Until then, the way described in the docs is perfectly fine. We're also going to talk about Messenger and how you can create endpoints that dispatch "messages" into Messenger (this is also something that API Platform has a bit about in their docs).

    Cheers!

  • 2019-06-17 Gabriel Mustiere

    Hey weaverryan, API Platform is really good for making projects quickly, but I've never met (or it's very rare), APIs without the need to make custom endpoints (I think the official documentation is confusing on the subject), do you plan to cover the subject, I'm in chapter 20. Thanks for the great job you do.

  • 2019-06-12 Vladimir Leitenberger

    what about "API Platform: OAuth2 Server" tutorial ?

  • 2019-05-27 Diego Aguiar

    Hey ElGovanni

    Sorry but I don't fully get your question. What you mean by "3rd party developers with limits"?

    Cheers!

  • 2019-05-25 ElGovanni

    Can we use api platform to publish it for 3rd part developers with limits?

  • 2019-05-21 Diego Aguiar

    :)

  • 2019-05-21 Peter Sorensen

    No-Docker API Platform tutorial. Finally! #dockersucks

  • 2019-05-16 weaverryan

    Hey @Fabio!

    We're not planning on it for the first tutorial, but it is on our radar for a future tutorial - I'll give it an internal upvote ;).

    Cheers!

  • 2019-05-16 Fabio Restrepo

    Hi, does this course cover live updates with mercure protocol

  • 2019-05-15 weaverryan

    Bah, ok *tomorrow*, I promise - we hit a last-second snag. Sorry about that!

  • 2019-05-13 weaverryan

    Wednesday :)

  • 2019-05-07 cybernet2u

    any news ?

  • 2019-04-26 Victor Bocharsky

    Hey Romeo,

    Thank you for your feedback! We will cover CRUD in this course, and will slightly mention GraphQL, but, unfortunately, GraphQL won't be a part of basics. We're going to cover GraphQL in a separate course - this topic deserves a separate tutorial.

    Cheers!

  • 2019-04-25 Dmitry Volya

    Awesome!

  • 2019-04-25 Romeo Tong

    It's good.
    I'm going to add GraphQL into Api-Platform and also with Symfony Flex.
    Did you include CRUD by GraphQL in this course? please.

  • 2019-04-24 Victor Bocharsky

    Hey Amin,

    Yes, we're going to cover oneToMany relation in this course, but probably not much complex than that, just simple oneToMany - it will be just basics of API-Platform.

    Cheers!

  • 2019-04-23 Amin Behravesh

    In Symfony I used to create a complex form, specially for oneToMany relations, you know using collection type, allow_add and other fascinating options, so is there anyway to have it in api platform? does this course cover things like this ?

  • 2019-04-16 Diego Aguiar

    Hey Manoj Kumar

    This course is totally focused on API Platform, so it won't cover how to develop an API in a TDD way. If you are interested in TDD, we have some courses about it (PHPSpec, PHPUnit, Behat), https://symfonycasts.com/tr...

    Cheers!

  • 2019-04-16 God Tier God

    This is what I was looking for !!

  • 2019-04-16 Victor Bocharsky

    Hey Manoj,

    Thank you for your interest in this topic! See my answer for more context: https://symfonycasts.com/sc...

    Cheers!

  • 2019-04-16 Victor Bocharsky

    Hey Imad,

    Unfortunately no, not in this episode at least. Security is a big separate topic, we're definitely going to cover it, but in next episodes. In this one we're going to cover basics only. Thank you for understanding!

    Cheers!

  • 2019-04-16 Manoj Kumar

    Will it cover TDD for APIs?

  • 2019-04-16 Manoj Kumar

    It would be nice to have it

  • 2019-04-15 Rafael

    Nice!

  • 2019-04-15 Diego Aguiar

    hahaha, we all have to wait ;)

  • 2019-04-15 Imad Zairig

    Cool,
    does this course cover API security with API-Platform ? :)

  • 2019-04-15 ElGovanni

    Finally

  • 2019-04-15 Manoj Kumar

    Waiting for it.......:D https://media2.giphy.com/me...