1000 search results

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…

4:51
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…

9:23
Bootstrapping a Test Suite

…database:create. But since we want this command to execute in the test environment, also add --env=test: Repeat that same thing with the doctrine:schema:create command: Perfect! Next, Api Platform has some really nice testing tools which... aren't released yet. Boo! Well... because…

4:29
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.

5:07
Passing data From the Server to Vue

…way. Add IriConverterInterface $iriConverter to get a service from API Platform. Remember: when you click on the Catalog component in the Vue Dev tools and look at the products data, each item that we get back from our API - whether it's a product, category…

6:46
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…

8:37
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…

39:20
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…

6:02
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…

5:02
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…

6:55
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.

4:32
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..…

6:41
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…

5:23
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 ->…

9:37
Head first into Symfony Cache, Redis & Redis Cluster (Andre Rømcke)

…application. So in our case on the eZ Platform side, we did change this to make sure we could take advantage of looking up several things at the same time. Instead of us having our API where you load one thing at the same time…

37:44
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…

45:03
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…

31:36
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…

9:56
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…

7:34
Serializer Error Renderer: JSON/XML Errors

…If you wanted to change this data, you could do that by adding your own custom normalizer. We actually talk about this in our API Platform Security Tutorial. You could decorate the ProblemNormalizer... and maybe just add or tweak some data or you could create…

5:40