Dynamic Groups without Caching
…And... that's fine! Symfony handles
all of that behind the scenes.
In the case of the resource metadata factory, API Platform itself decorates
that service multiple times... each "layer" adding a bit more functionality.
Normally, when we decorate a service from our application, our…
Resetting the Database Between Tests
…how can we empty the database before each test? There are a few answers,
but one common one you'll see in the API Platform world is called Alice. Find
your terminal and install it with:
composer require "alice:^2.7" --dev
This will install…
ACL: Only Owners can PUT a CheeseListing
…Ok, let's fix this!
The access_control option - which will probably be renamed to security in
API Platform 2.5 - allows you to write an "expression" inside using Symfony's
expression language. This is_granted() thing is a function that's available
in that…
Creating the User Entity
…gorgeous new Doctrine entity... but as far as API Platform
is concerned, we still only have one API resource: CheeseListing.
Next: let's expose User as an API Resource and use all of our new knowledge to
perfect that new resource in... about 5 minutes.
Calling the Controller & View Event
…model". Then, you could write a listener
to this event that transforms that Article entity into HTML by rendering the template.
This event isn't used anywhere in Symfony's core, but it is used extensively
inside API Platform. Internally, their controllers return objects. Then…
FrameworkBundle Recipe Part 2: The Kernel Class
…adopted by most browsers. We talk more about it inside our
API Platform Security
tutorial - but this setting shouldn't cause problems in most setups and is
definitely more secure.
So let's say "y" for all of these changes.
Keep going! Now we're…
Microservices Gone Wrong
…ve all gone out and built systems. And a team that I had the
opportunity to lead a number of years ago, we wound up building a platform. And
I'm gonna tell you a little about the background. But we made a bunch of…
Publishing a Listing
…waiting for our cheese.
So... how should we design this in our API? You might think that we need a custom
endpoint or "operation" in ApiPlatform language. Something like
POST /api/cheeses/{id}/publish.
You can do this. And we'll talk about custom operations…
Custom Logic Only for some Operations
…which
operation is being used. But if you start also using a PATCH operation or
custom operations, then this would not be enough.
Like many parts of ApiPlatform, a data persister has a normal interface -
DataPersisterInterface:
But also an optional, stronger interface that gives you…
PropertyFilter: Sparse Fieldsets
…about a protocol
that adds features to your web server. It was created by the API Platform team, and
if we scroll down a bit, they have a really good example.
Pretend that we have the following API. If we make a request to /books…
Passing Values to Stimulus
…a small percentage of your users to
be susceptible to CSRF attacks.
If you want to learn more, our API Platform 2 tutorial has a whole chapter on
SameSite cookies and CSRF tokens.
Next, let's turn to the other authentication use-case: API tokens.
Serializing Messages as JSON
…property into JSON.
We're not going to go too deep into Symfony's serializer component, but if you
want to know more, we go much deeper in our
API Platform Tutorial.
Anyways, this simple JSON structure is something any other system could
understand. So..…
DTO Quirks
…just delete it so that
the tests will pass.
But good news! Thanks to the API Platform team, this bug has been fixed and
should be released in API Platform 2.5.8. But since that hasn't been released yet
at the time of…
Query Extension: Auto-Filter a Collection
…for a specific
resource or even for a specific operation of a resource. They're... basically...
awesome.
Let's get our extension going: in the src/ApiPlatform/ directory, create a new
class called CheeseListingIsPublishedExtension. Make this implement
QueryCollectionExtensionInterface and then go to the Code ->…
Knowing your State Machines
…I'm sorry, show him or her later.
Quick about me. I do plenty of work on Happyr. We are a job advert platform -
it matches people with confidence, blah blah. I do plenty of Symfony things. I
run PHP meetups in Stockholm and I…
Back to the Basics (Symfony local Web Server)
…then you can get started really
easily. The problem is that it comes with many limitations and I'm going to
talk about that in minute.
Docker, well may be slow depending on the platform, especially on a Mac. I mean
it is for me…
Decoration: Override Core Services & AsDecorator
…wild? The answer to that is... sort of all over!
In API Platform, it's common to use decoration to extend core services like
the ContextBuilder. And Symfony itself uses decoration pretty commonly to add
debugging features while we're in the dev environment. For…
The await Keyword
…It's not very important in this case, but I'm actually
going to use this @id instead. This is called an "IRI" - it's a unique key
that API Platform adds to every resource. It's... just more useful than a
database ID or…
x
1000+