Chapters
36 Chapters
|
3:44:20
|
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!
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!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "3.1.x-dev", // 3.1.x-dev
"doctrine/annotations": "^2.0", // 2.0.1
"doctrine/doctrine-bundle": "^2.8", // 2.10.2
"doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.4
"doctrine/orm": "^2.14", // 2.16.1
"nelmio/cors-bundle": "^2.2", // 2.3.1
"nesbot/carbon": "^2.64", // 2.69.0
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.15", // 1.23.1
"symfony/asset": "6.3.*", // v6.3.0
"symfony/console": "6.3.*", // v6.3.2
"symfony/dotenv": "6.3.*", // v6.3.0
"symfony/expression-language": "6.3.*", // v6.3.0
"symfony/flex": "^2", // v2.3.3
"symfony/framework-bundle": "6.3.*", // v6.3.2
"symfony/property-access": "6.3.*", // v6.3.2
"symfony/property-info": "6.3.*", // v6.3.0
"symfony/runtime": "6.3.*", // v6.3.2
"symfony/security-bundle": "6.3.*", // v6.3.3
"symfony/serializer": "6.3.*", // v6.3.3
"symfony/stimulus-bundle": "^2.9", // v2.10.0
"symfony/string": "6.3.*", // v6.3.2
"symfony/twig-bundle": "6.3.*", // v6.3.0
"symfony/ux-react": "^2.6", // v2.10.0
"symfony/ux-vue": "^2.7", // v2.10.0
"symfony/validator": "6.3.*", // v6.3.2
"symfony/webpack-encore-bundle": "^2.0", // v2.0.1
"symfony/yaml": "6.3.*", // v6.3.3
"symfonycasts/micro-mapper": "^0.1.0" // v0.1.1
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.4
"mtdowling/jmespath.php": "^2.6", // 2.6.1
"phpunit/phpunit": "^9.5", // 9.6.11
"symfony/browser-kit": "6.3.*", // v6.3.2
"symfony/css-selector": "6.3.*", // v6.3.2
"symfony/debug-bundle": "6.3.*", // v6.3.2
"symfony/maker-bundle": "^1.48", // v1.50.0
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/phpunit-bridge": "^6.2", // v6.3.2
"symfony/stopwatch": "6.3.*", // v6.3.0
"symfony/web-profiler-bundle": "6.3.*", // v6.3.2
"zenstruck/browser": "^1.2", // v1.4.0
"zenstruck/foundry": "^1.26" // v1.35.0
}
}
7 Comments
Hi, I'm afraid this is not working (anymore? I'm on Api Platform Core version 3.2.13).
With this code :
I have the full Doctrine entity for
GetandGetCollection.If I remove the
provideroption, theGetresults as expected (only theidproperty) but theGetCollectionstill presents all the Doctrine entity properties.Hey @Guillaume!
Sorry for the trouble and the late reply. I just had some time to look into this and I can confirm your bug. It looks like there's already an issue open - https://github.com/api-platform/core/issues/6039#issuecomment-1959624424 - and I've added a bunch more detail. Hopefully the problem can be identified and fixed.
Cheers!
I'm relieved I'm not in cause there ;-)
Thank you for taking action to help fix the issue! :-) Your tutorial helps me so much in my journey learning to use Api Platform!
Hi!
The type hint annotation didn't work for me while writing (POST), but working while reading (GET).
(POST client with this data : {"addresses": [..., ...]}} ) ended up with bad conversion error because he was expecting an array of strings instead of an array of data. And it couldn't understand IRI either.
I had to manualy define the ApiProperty definition :
I hope this could help anyone !
By browsing this tutorial, I couldn't find a case where you do post embedded data since you separated Entities from ApiResources, so I can't figure if the problem is from my side or not.
Kind regards,
Jérémy
Hey @Jeremy!
Sorry for the epically slow reply - it's a super busy time of year for us!
Anyway, the behavior you're seeing is super weird. But I LOVE what you dove in and found! This is expert-level configuration. Thank you for sharing that!
Cheers!
Hi, can 'entityClass' be set through yaml resources? After some digging in YamlResourceExtractor I found that we can set 'stateOptions' however this creates ApiPlatform\Metadata\Tests\Fixtures\StateOptions rather then the desired ApiPlatform\State\OptionsInterface\StateOptions.
Hey @Joe-L!
I'm looking at that same class, and I don't think it's possible. There are actually multiple different
StateOptionsclasses based on if you're using the ORM vs elastic search vs other stuff. And it looks like that class was only updated to support the "elastic search" `StateOptions - https://github.com/api-platform/core/blob/main/src/Metadata/Extractor/YamlResourceExtractor.php#L409-L411 - and as you noticed... I'm not sure that this is even the correct class to use in that situation!So, no I think you're out of luck. I'm guessing there is a way to hook into the "resource metadata system" to add it manually... I may have done something kind of similar in the API Platform version 2 of this tutorial - https://symfonycasts.com/screencast/api-platform2-security/resource-metadata-factory in case that helps. I'm told that some namespaces have changed for doing this in API Platform 3, but nothing super big.
Cheers!
"Houston: no signs of life"
Start the conversation!