Chapters
39 Chapters
|
4:45:13
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3, <8.0
Subscribe to download the code!Compatible PHP versions: ^7.1.3, <8.0
-
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!
26.
Automatic Serialization Groups
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 works great for Symfony 5 and API Platform 2.5/2.6.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3, <8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^2.1", // v2.4.5
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.13.2
"doctrine/doctrine-bundle": "^1.6", // 1.11.2
"doctrine/doctrine-migrations-bundle": "^2.0", // v2.0.0
"doctrine/orm": "^2.4.5", // v2.7.2
"nelmio/cors-bundle": "^1.5", // 1.5.6
"nesbot/carbon": "^2.17", // 2.21.3
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0", // 4.3.1
"symfony/asset": "4.3.*", // v4.3.2
"symfony/console": "4.3.*", // v4.3.2
"symfony/dotenv": "4.3.*", // v4.3.2
"symfony/expression-language": "4.3.*", // v4.3.2
"symfony/flex": "^1.1", // v1.21.6
"symfony/framework-bundle": "4.3.*", // v4.3.2
"symfony/http-client": "4.3.*", // v4.3.3
"symfony/monolog-bundle": "^3.4", // v3.4.0
"symfony/security-bundle": "4.3.*", // v4.3.2
"symfony/twig-bundle": "4.3.*", // v4.3.2
"symfony/validator": "4.3.*", // v4.3.2
"symfony/webpack-encore-bundle": "^1.6", // v1.6.2
"symfony/yaml": "4.3.*" // v4.3.2
},
"require-dev": {
"hautelook/alice-bundle": "^2.5", // 2.7.3
"symfony/browser-kit": "4.3.*", // v4.3.3
"symfony/css-selector": "4.3.*", // v4.3.3
"symfony/maker-bundle": "^1.11", // v1.12.0
"symfony/phpunit-bridge": "^4.3", // v4.3.3
"symfony/stopwatch": "4.3.*", // v4.3.2
"symfony/web-profiler-bundle": "4.3.*" // v4.3.2
}
}
6 Comments
Hello ! Shouldn't we instead create a file specifically designed for anything "global" like adding default groups, rather than using it in the AdminGroupsContextBuilder which, as the name suggests, is mostly meant for the admin group?
So we could build a set of files that could be used from project to project without worrying about the rest.
EDIT : Okay sorry, we delete it in the next step. Coooool
Hey, everyone!
Man, I love this.
Even better would be to iterate over all the user roles and create the respective groups, instead of just checking for the ROLE_ADMIN.
Something like:
role_admin:read
role_admin:write
role_admin:item:get
role_admin:item:patch
role_admin:item:delete
role_admin:collection:post
role_user:read
role_user:item:get
...
It gives full control and it is easier to understand who has access to what, in my opinion.
Do you think that is OK or is it overkill?
Amazing work!
Hey André P.
Honestly it's totally depends on project you work, sometimes it's enough to just check ROLE_ADMIN, but sometimes you may need to make more complex checks it's totally up to you and your project =)
PS do not do something complex if you don't really need it! Simplicity FTW!
Cheers!
Hey, sadikoff !
Wise words indeed.
I'll keep that in mind. I guess I was hyped with the possibilities, hahah.
Thanks you!
in addDefaultGroups you are sometimes returning nothing as seen in return;
But then you use the same function in array merge which always expects an array, am I wrong or should you at least return empty array in case the resource class is null?
Hey gabb!
Nice catch! You are right! I think PHP is being "friendly" to me here - but I should totally be returning an empty array from
addDefaultGroupsinstead of nothing/null. Thanks for asking about this :).Cheers!
"Houston: no signs of life"
Start the conversation!