Input DTO Update Problems
…when the serializer deserializes the JSON into the
CheeseListingInput, the owner property will be null... and then we pass that
null value onto $cheeseListing->setOwner(). When API Platform tries to save
the CheeseListing with no owner... error!
But... let's back up: there's a…
Type Validation
…argument is not nullable, if you tried to send a price
field set to null that value would not be legal to set on this property.
When this happens, API Platform returns a 400 error. It's not a validation error
exactly... but it effectively…
Filter Autowiring
…option and
sets those as named arguments on that service. Why do we care about how our
filter objects are instantiated? Because when API Platform registers the service,
it also sets it to autowire: true. Yep, this means we can access services
in our filter…
Ajax with Axios
…for
GET /api/products.
The best way to see how this works is... to try it! Let's see... hit Execute
and... here's the response body. We already have a set of products in the
database.
If you haven't used API Platform before …
Filtering the Products
…done a bit of work behind the scenes in API platform to
allow us to fetch all the products for a specific category.
Here's how it works: we can enter a category's IRI into this box: so,
/api/categories/ - and then 24 to…
Diving into the Normalizer Internals
…The embedded cheeseListings
data has them... but each user does not.
What's going on?
When you work with API Platform, the Symfony serializer has many normalizers.
I'll hit Shift+Shift and search for a class called ItemNormalizer. There are
a bunch of these …
The Delightful World of Vue
…can sink your teeth into, even if JavaScript isn't your main gig. In this tutorial, we'll build a real-world "Products" area for our site using an API-Platform-powered API. Will it be a single-page application (SPA)? Nope! Not in this…
SymfonyCon 2019 Amsterdam Conference Videos
…experiences at this sold-out event. The conference featured 3 tracks, 30 speakers and 33 talks ranging from watching the live release of Symfony 5, to API Platform, Messenger, and many more things.
Ready to watch (or re-watch) the presentations? The videos are available…
Symfony Live Lille 2019 (French)
…Symfony (évidemment), mais aussi Mercure, Doctrine, API Platform ou encore React et Redux ainsi que des bonnes pratiques sur les meilleurs bundles et outils pour vos applications Symfony, et d’autres passionnants sujets !
Vous êtes prêt à regarder (ou revoir) les présentations ? Les vidéos sont…
SymfonyCon 2018 Lisbon Conference Videos
…meet and share their experiences around Symfony. And over 25 speakers presented on topics ranging from the new Symfony web server, to Messenger, to API Platform and so much more.
Ready to watch (or re-watch) the presentations? The videos are now available to everyone.
Client Credentials
…new "Chicken Oversight Operations Platform", or
COOP site has just launched! With COOP, you can login to the site and
collect your chicken eggs, unlock the barn, and do all kinds of other things
just by clicking a button.
Noticing that COOP has an API…
Environment Variables
Open config/packages/framework.yaml. We don't need to be authenticated to use this
raw user content part of GitHub's API:
But if we hit this endpoint a lot, we might hit their rate-limiting, which is pretty low
for anonymous users. So…
API Setup & AJAX with fetch()
…re not going to spend a lot of time talking
about the API side of things: we'll save that for a future tutorial. That's when
we'll also talk about other great tools - like ApiPlatform - that you won't see
used here.
Anyways…
Embedded Write
…is not writable via this operation.
Let's think about this. We're updating a DragonTreasure. This means that API
Platform is using the treasure:write serialization group. That group is
above the owner property, which is why we can change the owner.
But if…
Filtering on Relations
…and hit "Execute".
Let's see... That worked! This shows all treasures owned by any user whose username
contains maug. Pretty cool!
Ok squad: get ready for the grand finale - Subresources. These have seriously
changed in API Platform 3. Let's dive into them next.
Subresources
…wildcards" in your URL. Pass user_id set to a new Link() object. There are
multiple... we want the one from ApiPlatform\Metadata.
This object needs two things. First, point to the class that the {user_id}
is referring to. Do that by passing a…
On Authentication Success
…look something like '/api/users/'.$user->getId(). But I don't want to hard code
that because we could potentially change the URL in the future. I'd rather have API
Platform generate that for me.
And fortunately, API Platform gives us an autowireable service…
Decorating the Core State Provider
…class - make sure to
get the one from ORM.
And yup! That is a valid service id. There is also a harder-to-remember service
id, but API Platform provides a service alias so that we can just use this. Lovely!
Ok, go test go…
x
1000+