Chapters
25 Chapters
|
2:34:05
|
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": "*",
"knplabs/knp-time-bundle": "^1.18", // v1.19.0
"symfony/asset": "6.1.*", // v6.1.0-RC1
"symfony/console": "6.1.*", // v6.1.0-RC1
"symfony/dotenv": "6.1.*", // v6.1.0-RC1
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.1.*", // v6.1.0-RC1
"symfony/http-client": "6.1.*", // v6.1.0-RC1
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.1.*", // v6.1.0-RC1
"symfony/ux-turbo": "^2.0", // v2.1.1
"symfony/webpack-encore-bundle": "^1.13", // v1.14.1
"symfony/yaml": "6.1.*", // v6.1.0-RC1
"twig/extra-bundle": "^2.12|^3.0", // v3.4.0
"twig/twig": "^2.12|^3.0" // v3.4.0
},
"require-dev": {
"symfony/debug-bundle": "6.1.*", // v6.1.0-RC1
"symfony/maker-bundle": "^1.41", // v1.42.0
"symfony/stopwatch": "6.1.*", // v6.1.0-RC1
"symfony/web-profiler-bundle": "6.1.*" // v6.1.0-RC1
}
}
9 Comments
Hey! Love the video!
How would one utilise this binding an argument for a specific class using PHP syntax in services.php?
Hey Kaybie,
Personally, I follow Symfony best practice using yaml configuration for my projects, so haven't done that in pure PHP, but here's the link to the docs with an example in yaml/xml/php : https://symfony.com/doc/current/service_container.html#binding-arguments-by-name-or-type
I hope that helps :)
Cheers!
In this course page text (NOT THE VIDEO) $isDebug for yaml is written with single quotes as '$isDebug' and not as $isDebug as shown in the video. For coherence since it is a Script I would write it in the same way but hey!! I tested it with both version and it works even with single quotes!!
Hey Leonard,
Good catch! The quotes isn't important in that case, so you can use both, or even write it without them and it should still work. Yeah, minor mismatch with the video, but since it's not important - it can be ignored.
Thanks for the head ups!
Cheers!
If I need the a Kernel Variable I simply inject the KernelInterface
This way I don't need a binding in services.yaml
Is this an other way or bad practice?
hey @Blanx
let's think different, you need 1 little variable (string, bool or any type) so you are injecting the whole big Container to use just this 1 value? Won't it be easier to inject only var you need with
services.yaml?As for me it will be much cleaner way and also it will be more performant way
Cheers!
Hey @sadikoff, thx for your reply!
You have a good point :) The trade off, that it is more complicated. I thought it was no big deal, since the Kernel is loaded anyway and Symfony is so smart it only uses a reference...but maybe this was wishful thinking.
IIRC it has nothing with Symfony, but PHP and of course it will be a reference to class, but what will be better to have value immediately or get some class from reference and then call some method to get same raw value?
Cheers!
@sadikoff Thx for your explanation, appreciate it!
"Houston: no signs of life"
Start the conversation!