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!
48.
UUID Quirk with "id" Name
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.
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
}
}
15 Comments
HI! Wonderful course, thanks for your work!
Is there a chance that part 4 will be released at all?
Hey Drutpro!
Thank you for your feedback! Yes, we definitely want to release more courses about API Platform, this is a great tool with huge capabilities. Unfortunately, I'm not sure when it might be released, for now we're working on many other topics that have bigger priorities for us now.
P.S. But if you have some topics which you would like to see in that 4th episode of API Platform course - please, feel free to share with us in the comments below! It would definitely helpful for us when we will work on planning a new episode!
Cheers!
I can give some more specifics too. We will, soon, start releasing new courses for API Platform 3 (which was just released). When we do that, we will take a look at all the possible topics and cover what we think is most important. So if you'd like to see something, indeed, let us know!
Cheers!
Hey there ,
When is Part 4 coming?
Really love your work. Thanks a bunch! Greetings from Romania!
Hey Bancuadrian,
Thank you for your interest in SymfonyCasts tutorials! Unfortunately, we don't have any plans for recording another ApiPlatform course in the nearest future - many other good things are coming soon. But we will definitely want to do it some day. For now, you can watch for upcoming tutorials on this page: https://symfonycasts.com/co...
Thank you for your patience and understanding!
Cheers!
I am not sure about gains of setting UUID from the frontend. But with that requirement this article may be only way to go.
Personally I would ditch the UUID setup from frontend and also autoincrement id altogether and use timebased uuid1 type generation (for MySQL). Performance drop should be very small. But using uuid4 and MySQL it's completely different story.
For MySQL 5 I would use custom converter for uuid to binary and reverting order of uuid. Just google uuid binary and mysql.
Hey Peter L.!
That seems like a fine solution :). If you're able to set the UUID from the frontend.... then for the situations when you "don't care", you definitely want the UUID to be set directly. I'm not familiar with MySQL's functionality for doing this (you certainly seem to know more about it than I do), but that is definitely a legitimate way of being able to auto-set that column.
Cheers!
Sorry, I read my comment again, I did not mean to sound like that. I do not have more experience, only in different area.
Also thanks for the idea of setting uuid from frontend, it is usefull in PWA when it's in "no internet" state. Finally my temporary identifier I used for this is gone.
My experience with uuids was to choose best choice for identifier if you are using mongodb, mysql and sqlite in one project.
No worries Peter L. - I didn't take it harshly, but thanks for your follow-up :).
Hey Ryan, can you give us some spoilers about how we could add some custom endpoints to our APIs?
I'm working on a project that is already underway and I will definitely need this. There is a lot of commands that I'll need to trigger, consume some queues, query some process status, etc... Some spoilers would help me a lot.
And also.. when do you think that fourth part of this course will be release? Thanks again
Hey Carlos!
> can you give us some spoilers about how we could add some custom endpoints to our APIs?
Spoilers! :) The tl;dr for custom operations would be that (A) I try to avoid them when possible by making RESTful endpoints where I can trigger custom code - https://symfonycasts.com/sc... - which would still allow you to trigger custom code (but won't work for all situations). Next, (B) I would try to use the Messenger integration with API Platform. This allows you to return values from your handlers, so it's pretty powerful And (C), finally, if none of that works or feels right, create a custom controller/action - https://api-platform.com/do... - and don't feel bad about it. The worst part of this is that it doesn't support GraphQL (you probably don't care) and if perfect documentation is important to you, then you may need to do some more work with your annotations to help out. If you're creating a custom operation... then API Platform isn't doing "all that much" for you anyways, except for helping integrate with the documentation.
> And also.. when do you think that fourth part of this course will be release? Thanks again
It likely will wait a few months, unfortunately, because we have some other super high priority things to cover like Symfony UX/Stimulus/Turbo &
Symfony 5.2 to name the 2 most important things at the moment. But if you have any other problems or questions, let me know - it can help me make sure I've got the right examples for the tutorial.
Cheers!
Do you think, that symfony 5.2 will solve the issues with UUID's that will part of symfony core ?
Do you will later update the course lecture to this new feature ?
https://symfony.com/blog/ne...
Symfony 5.2 includes a Uid normalizer to serialize/deserialize UUIDs and
ULIDs. It also introduces a new validation constraint to validate ULIDs.
https://symfony.com/blog/ne...
Symfony 5.2 provides new Doctrine types to help you work with UUID/ULID values in your entity properties.
Hey Miky!
Excellent questions!
I haven't used the UUID stuff from 5.2 yet, but I believe that it would not affect too much. What I mean is, it would ultimately work the same, you would just be installing a Symfony component, instead of something from ramsey. In other words, the UUID install chapter - https://symfonycasts.com/sc... - would look different, but I'm pretty sure the rest of the process will continue on more-or-less the same. Let's look at some specifics:
A) The Symfony5.2 UUID component basically accomplishes the same as ramsey/uuid
B) "Symfony 5.2 includes a Uid normalizer to serialize/deserialize UUIDs" - this is nice, but API Platform also comes with a normalizer for ramsey/uuid. So the result should be the same :).
C) "Symfony 5.2 provides new Doctrine types to help you work with UUID/ULID values in your entity properties" - this would mean that you wouldn't need to install ramsey/uuid-doctrine, but both add a "Doctrine type" so it should work the same.
The quirk that we "work around" in this chapter doesn't come from the UUID system, it really comes from the fact that API Platform does not want to allow you send a property called "id" when you are creating an object. That would be true no matter what that id field is (e.g. a UUID from ramsey or Symfony's UUID). This is ultimately a problem that would need to be addressed in API Platform :).
Let me know if that helps clarify things!
Cheers!
"Houston: no signs of life"
Start the conversation!