Chapters
20 Chapters
|
1:53:05
|
Login to bookmark this video
-
Course Code
Login or register to download the code!
Login or register to download the code!
-
This Video
Login or register to download the video!
Login or register to download the video!
-
Subtitles
Login or register to download the subtitles!
Login or register to download the subtitles!
-
Course Script
Login or register to download the script!
Login or register 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!
This tutorial works perfectly with both Symfony 7 & 8!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"php-cs-fixer/shim": "^3.46", // v3.46.0
"phpdocumentor/reflection-docblock": "^5.3", // 5.3.0
"phpstan/phpdoc-parser": "^1.25", // 1.25.0
"symfony/asset": "7.0.*", // v7.0.3
"symfony/asset-mapper": "7.0.*", // v7.0.2
"symfony/console": "7.0.*", // v7.0.2
"symfony/dotenv": "7.0.*", // v7.0.2
"symfony/flex": "^2", // v2.4.3
"symfony/framework-bundle": "7.0.*", // v7.0.2
"symfony/monolog-bundle": "^3.0", // v3.10.0
"symfony/property-access": "7.0.*", // v7.0.0
"symfony/property-info": "7.0.*", // v7.0.0
"symfony/runtime": "7.0.*", // v7.0.0
"symfony/serializer": "7.0.*", // v7.0.2
"symfony/stimulus-bundle": "^2.13", // v2.13.3
"symfony/twig-bundle": "7.0.*", // v7.0.0
"symfony/ux-turbo": "^2.13", // v2.13.2
"symfony/yaml": "7.0.*", // v7.0.0
"symfonycasts/tailwind-bundle": "^0.7.1", // v0.7.1
"twig/extra-bundle": "^2.12|^3.0", // v3.8.0
"twig/twig": "^2.12|^3.0" // v3.8.0
},
"require-dev": {
"symfony/debug-bundle": "7.0.*", // v7.0.0
"symfony/maker-bundle": "^1.52", // v1.53.0
"symfony/stopwatch": "7.0.*", // v7.0.0
"symfony/web-profiler-bundle": "7.0.*" // v7.0.2
}
}
9 Comments
You don't really need serializer.
Just use public readonly in your model class and it works without the serializer package:
Hey @dannyvdknaap ,
Thanks for this tip!
Cheers!
nice, so it's almost like Asp.net core
Generate code on Windows: Alt + Insert
Hey DXS,
Thanks for this tip for our Windows users! :)
Cheers!
Hello,
This question can be simple for you but I am asking to understand clearly. Sorry for this.
My question is are we creating a class which name is Starship and we are inserting the values onto that class right?
I mean by doing new Starship in controller, actually are we sending our values to Model Starship class to hold them?
thank you
Hey @Mahmut-A
Yes, we basically transformed an associative array into a list of
Startshipobjects. TheStarshipclass holds all the data into propertiesI hope it's more clear now. Cheers!
the way Starship model is created:
Is this some sort of recommended or best practice way to create models ? Because for now I feel better in keeping it simple and coding class the old fashion way:
The latter way I simply get the end result and I don't need to learn about serializer and serialization for now and I will learn it if/when I need to. Or is this essential part of symfony and shouldn't be skipped ?
Hey @John-S,
Your class is totally valid! In fact, now that php has typed properties there is definitely a shift back to this. The primary reason for getters and setters was type safety. Keep in mind if you have any validation or logic needed when setting your properties, you'll need to use a private properties with getters/setters.
Serialization will work just fine with your object.
Cheers!
"Houston: no signs of life"
Start the conversation!