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!
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
I have a question about
Is it the same as
Hey Francois,
Well, almost :) In the 2nd case if the
browse()method will be called without arguments - the$timeFormatterwill be, by default, set tonew DateTimeFormatterwhile in the first case, it will throw because the 1st argument is required there :) So, it's just the default value for the first argument in your 2nd example.And so, the second case should be written as:
In case you want to allow only
DateTimeFormatterinstances as the 1st argument.Cheers!
My original concern is that the
$timeFormatterfunction argument seems to pop out of nowhere (i.e. I do not see such kind of variable out there).I will try to recap my thoughts here:
DateTimeFormatterclass is a service, i.e., it has no propertyHey Francois,
Then I'm still not sure I understand you. I suppose you wrote that
$timeFormatter = new DateTimeFormatterin your method signature, no? Because I don't see it in this video.Great, then the Symfony Dependency Injection Container will create and inject it for you. But still don't see what you mean about "has no property".
Static methods can be called without instantiating a class because they are static. For normal methods - you can call them only from an instance of a class of course.
I hope it helps!
Cheers!
I looked at the documentation for Dependency Injection. If I understand well, this is not a base level PHP behavior, but something extra built on top of PHP. Services use dependency injection.
Is this right?
François
Hey Francois,
Yes, sure! you may think of dependency injection (DI) and dependency injection container (DIC) as patterns. And yes, it's not a native PHP function but a behavior implemented in a Symfony component.
Cheers!
Hey,
I get at using this bundle the exception ClassNotFoundError in the file mixed_vinyl\vendor\symfony\translation\LocaleSwitcher.php at line 37.
Hey Stefaaan,
Do you have installed the PHP intl extension on your computer?
Hey MolloKhan,
thanks for your reply.
No, i hadn't installed this extension. After installing it in the php.ini and restarting the local web server it works. Thank you.
"Houston: no signs of life"
Start the conversation!