Api Tests Assertions
... Create a client object with
$client = self::createClient().
This creates a, sort of, "fake" client, which is another feature that comes from
the API Platform test classes. I say "fake" client because instead of making ...
Mercure des UIs toujours synchronisées avec la BDD Kévin Dunglas
...
Après avoir découvert le protocole, verrons comment :
installer un serveur Mercure
découvrir le serveur côté client
s’abonner à des mises à jour
publier des mises à jour avec Symfony et API Platform (qui disposent déjà du support officiel du protocole)
mettre à jour des apps React avec les données envoyées par Mercure
The Delightful World of Vue
... 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 tutorial - because it turns out, integrating Vue into a "traditional ...
Dynamic Groups without Caching
... don't have this option - API Platform
guesses a shortName based on the class name.
The shortName most importantly becomes part of the URL. Check this out: execute
a GET request to /api/cheeses. Then, use the web debug ...
Embedded Write
... that was
not configured to cascade persist operations for entity User.
If you've been around Doctrine for awhile, you might recognize this strange error.
Ignoring API Platform for a moment, it means that something ...
Filtering Relation Collection
... collection extension is called.
But when we make a call to a user endpoint - like to GET a single User -
API Platform is not making a query for any treasures: it's making a query for
that one User. Once it has that User ...
Logout Passing API Data to JavaScript
... API Platform and it's not being processed by API platform. But... our
normalization groups are configured in API Platform. So how did the serializer
know to use those?
The answer to that, as best I can tell, is that ...
Validation
... Internally, API platform creates a DragonTreasure object...
but doesn't set any data on it. And then it explodes when it hits the database because
some of the columns are null.
And, we expected this! We're missing validation ...
UUID as a API Identifier
... it still uses the id.
So how do we tell API Platform to use the uuid property as the "identifier"?
It's actually pretty simple! And we talked about it before.
Go to the top of User. Every API Resource needs an identifier ...
Completely Custom Field via a Data Provider
... different ways. Okay, not 47, but there
are a few ways and we'll look into several of them because different solutions
will work best in different situations.
For the first solution, let's think about how API Platform works ...
API Debugging with the Profiler
... We're going to be doing some seriously cool and complex stuff with API platform.
So before we get there, I want to make sure we have a really awesome debugging
setup. Because... sometimes debugging APIs can be a pain ...
Decorating the Core State Provider
... DragonTreasure, way up on top, inside the ApiResource attribute, add
provider then the service ID, which is the class in our case:
DragonTreasureStateProvider::class.
So now, whenever API Platform needs to "load" a dragon ...
Setting a Custom Field Via a Listener
... populated it in a data provider:
But in reality, there are multiple ways that we could set that field. The data
provider solution is the pure API Platform solution. The downside is that if
you use your User object in some code ...
Completely Custom Resource
... need to tweak the config to tell
API Platform to look in that new spot:
Easy peasy!
Back in the new class, for simplicity - and... because this class will stay
very simple - I'm going to use public properties: public ...
Output Properties Metadata
... them.
API Platform creates a unique "model" for each different way that a
resource might be returned based on your serialization groups. And when you
create an output DTO, it creates yet another model class to describe ...
More Formats HAL CSV
API Platform supports multiple input and output formats. We know that we can go to
/api/treasures.json to see JSON, .jsonld to see JSON-LD or even .html to
see the HTML output format.
But adding this extension to the ...
ApiResource access_control
There are two big parts to security in any app. First, how does your user authenticate?
How do they log in? Honestly, that is the trickiest part... and it has really
nothing to do with API Platform. We're authenticating ...
Relations and IRIs
I just tried to create a CheeseListing by setting the owner property to 1: the
id of a real user in the database. But... it didn't like it! Why? Because in
API Platform and, commonly, in modern API development in ...
Auto-set the Owner Entity Listener
... good thing. Hmm. Don't worry, I'll tell you which one I would use and why.
Our options include an API Platform event listener - a topic we haven't talked
about yet - an API Platform data persister or a Doctrine event ...
Custom Resource Item Provider
... there's a dayString inside! Notice that, in DailyQuest,
we never configure what the URL should look like. You can do that, but by default,
API Platform automatically figures out what the route and URL should look like ...
1016
API Platform
Filter Results