Chapters
48 Chapters
|
5:13:28
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
04.
Custom Logic Only for some Operations
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
This tutorial also works great with API Platform 2.6.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^2.1", // v2.5.10
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.12.1
"doctrine/doctrine-bundle": "^2.0", // 2.1.2
"doctrine/doctrine-migrations-bundle": "^3.0", // 3.0.2
"doctrine/orm": "^2.4.5", // 2.8.2
"nelmio/cors-bundle": "^2.1", // 2.1.0
"nesbot/carbon": "^2.17", // 2.39.1
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0", // 5.2.2
"ramsey/uuid-doctrine": "^1.6", // 1.6.0
"symfony/asset": "5.1.*", // v5.1.5
"symfony/console": "5.1.*", // v5.1.5
"symfony/debug-bundle": "5.1.*", // v5.1.5
"symfony/dotenv": "5.1.*", // v5.1.5
"symfony/expression-language": "5.1.*", // v5.1.5
"symfony/flex": "^1.1", // v1.21.6
"symfony/framework-bundle": "5.1.*", // v5.1.5
"symfony/http-client": "5.1.*", // v5.1.5
"symfony/monolog-bundle": "^3.4", // v3.5.0
"symfony/security-bundle": "5.1.*", // v5.1.5
"symfony/twig-bundle": "5.1.*", // v5.1.5
"symfony/validator": "5.1.*", // v5.1.5
"symfony/webpack-encore-bundle": "^1.6", // v1.8.0
"symfony/yaml": "5.1.*" // v5.1.5
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", // 3.3.2
"symfony/browser-kit": "5.1.*", // v5.1.5
"symfony/css-selector": "5.1.*", // v5.1.5
"symfony/maker-bundle": "^1.11", // v1.23.0
"symfony/phpunit-bridge": "5.1.*", // v5.1.5
"symfony/stopwatch": "5.1.*", // v5.1.5
"symfony/twig-bundle": "5.1.*", // v5.1.5
"symfony/web-profiler-bundle": "5.1.*", // v5.1.5
"zenstruck/foundry": "^1.1" // v1.8.0
}
}
6 Comments
Hi
A couple of things:
First, I work mostly with graphql on API-Platform and would appreciate if you create a specific tutorial for that.
Secondly, with API-Platform graphql, I would normally do this type of customization per/post persist on the stages.
Is there any downside of using stages as opposed to data persisters? Why use one or the other? Thanks.
Code example on src/Stages/DeserializeStage.php
Hey Bernard A. !
Nice to chat with you :). I believe the short answer is this: data persisters work for graphql or REST whereas stages are graphql only. So, if you're using graphql (caveat: I'm not very familiar with API Platform's GraphQL), there shouldn't really be any advantage or disadvantage. Frequently in the API Platform docs, they recommend solutions that "work everywhere" vs GraphQL or REST-specific solutions... just for simplicity I think :). For REST, iirc, the events system (iirc) is unique to it (and not included in GraphQL).
Cheers!
Hi
Thanks for your reply! Though you elegantly sidestepped the issue of the graphql tutorial.:)
Lol, guilty! I can't remember if I did that on purpose or not! I'll add your vote to our internal list... but probably not something we would do anytime too soon. However, we will need to, at some point in the not TOO distant future, refresh our API Platform tutorials. And when we do, that'd be the time to do it.
Cheers!
@weaverryan can you please answer this question?
https://stackoverflow.com/q...
Hey Anton!
Hmm, yea, I’m not sure! It sounds like the key is security, since you mentioned that removing a role fixes it. The question would be: can you get it to work with zero security? And can you also successfully trigger a 403 by using a role your user doesn’t have? You want to first see if either the success response or 403 response is causing the problem.
Cheers!
"Houston: no signs of life"
Start the conversation!