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
}
}
5 Comments
Hello dear SymfonyCast,
I have created a Processor where I want to check if the is a new User entity being posted.
I want to create a additional resource/ new entity UserProfile when this happens.
But I keep getting an error: Unable to generate an IRI for the item of type "App\ApiResource\UserProfileApi"
I have dealt with this error before, but know I cant really figure out how to deal with in this situation.
I tried setting it up within the mapper, where I get the same issue, but it does create a UserProfile after creating the User entity.
I thought maybe if I create the user First within the StateProcessor with the $this->persistProcessor and then proceed with creating the UserProfile but it did not work out as I thought.
I have AppFixtures where I can succesfully create userProfile after creating a User with no problems, so I am a little stuck.
I was thinking about creating a eventSubscriber/ Listener that check if a new User has a UserProfile, if not then create one and store it
I hope to get some pointers how to resolve this issue.
State Processor:
UserProfileApi:
UserAPi Resource:
Hey @Teddy-B!
I know this is now super old and I don't have the exact answer, but:
generally means that there is a
UserProfileApiobject, but it has no id (id is null), so the IRI generation fails.Cheers!
Thanks Ryan I still appreciate your answer
Hello Rayan
I have created a "UserApi mapper" to map the Doctrine User entity and a "BlogApi mapper" to map the Doctrine Blog entity. I try to create a sub-resource of the type /api/users/{id}/blogs, with itemUriTemplate: '/users/{userId}/blogs/{blogId}'. However, I get an error :
Example of how to reproduce a bug :
Hey @mcdzign!
Hmm. That error - "Unable to generate an IRI" - can happen for several reasons, the simplest being that the
BlogApiobject (for some reason) has null for its id. But there are other things that can cause this. When I see this error, I open the profiler for that request (you can go to/_profilerto find the most recent requests) and then go to the Exceptions tab. This error will be on top, but usually there is a nested error further below that may give more granular details about what's going on. Do you see a 2nd exception message at the bottom?Cheers!
"Houston: no signs of life"
Start the conversation!