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
}
}
26 Comments
I add a suggestion that can avoid wasting an hour of attempts to make the call to the _wdt route work!
install this, after composer require debug command:
composer require symfony/apache-packHey @pasquale_pellicani ,
Thanks for this tip! Indeed, if you're using Apache instead of built-in Symfony web server that we're using in the screencast - you would need that
symfony/apache-packpackage that will bring an.htaccessfile into your app.Cheers!
Hello,
I have two questions for this topic:
Hi @Mahmut-A
Can you provide more details what exactly you want to achieve?
Cheers
Hi Sadikoff,
Oh, I got it. That is a tricky moment
debugis an installation alias, so once you installed debug pack, you should forget about it, and if you want to uninstall it, you should uninstall each package separately.Cheers!
Could you also please explain how to remove bundles or packs?
Hey @tomoguchi ,
How to remove? It's as easy as execute
composer removecommand. If you use Symfony Flex - it will also remove config files. If no, you will need to do it manually. But basically, you just need to drop the package from your composer.json file, for this you leverage the command I mentioned above:composer remove ...and then you need to disable the bundle in theconfig/bundles.php- just literally drop the related namespace from there. Then clean up any related config files in theconfig/dir. I think that's all :)Cheers!
hello @Victor does that also removes the generated files, setting and autowirings
composer require some-bundlecreated?Hey @tomoguchi ,
Yes, it has to remove those files too. Well, not the files you created manually but the files that were created by Symfony Flex recipe. But it will happen only if you have Symfony Flex enabled and allowed in your project.
Cheers!
adding this inside controller method:
each use of dump() is adding 2 seconds to execution time. So this takes 4seconds to load the script.
I intend to use it quite a lot to track things down is there a way to make it quicker ?
Hey @John-S, this is indeed odd. To confirm, removing one
dump()reduces the request time to ~2 seconds and adding adump()increases to ~6 seconds? Do you see the dump output as expected in the profiler?1 dump() 2 seconds.
2 dump() 4 seconds.
3 uses of dump() profiler line:
dump 6078.2 ms / 2 MiB
probably something with the settings but just not sure what.
Does it happen on every request? In particular when you don't change the code
Do you experiment the same behavior with a different Symfony app?
I believe you may have added by mistake a
sleep()somewhere in your vendors. Try re-installing themCheers!
Is it ok that dump() increases every request time to 2seconds?
I haven't installed the monolog bundle but installed symfony/stopwatch --dev. I have short array on my controller and using dump($simpleArray) on it. It now it takes 2seconds to load every request (dump 2037.7 ms / 2 MiB). Is this ok ?
Hey John,
It depends on the data you're trying to dump. If you're dumping heavy objects, the serialization may really take long time. Also, sometimes it depends if you're using a virtualization tool like Docker or no. With virtualization tools numbers can be really much more increased.
But in short, that's OK, because you should use
dump()/dd()features only in dev mode and never should use it on production.Cheers!
hello,
I'm having a hard time following which packages require "--dev" addon.
For example I see both the symfony/debug-bundle on docs and on packagist website recommended installation as "composer require symfony/debug-bundle" but here(composer.json) is under require-dev. My installation settled it under "require".
how to do it right ?
p.s. I know this is introductory tutorial but i really try to install all features individually and not packs so I can keep the track on and know what's what.
Hey @John-S
To make composer install things under the
require-devkey, you need to pass the--devflag. You can also manually move the dependencies from one key to another in case you forgot to add the flag.Cheers!
Hello,
Could you please show how to remove debug from the bar? I did composer remove debug. but still I see the debug bar.
thank you
Hey @Mahmut-A
Can I ask why? You're the first one I know who doesn't like it - lol
Seriously, that debug toolbar is only loaded on the "dev" environment. You can remove it by deleting the bundle's entry in
config/bundles.phpCheers!
Hi,
the first reason is actually I wanted to test to remove a package from composer. so when I used composer remove command, composer.json did not delete this package. so I did not want to wrong thing to affect all symfony environment.
the second reason, I am building my project in web service apache. so I do not want show the debug to clients.
then, I understand that if any package is need to remove, I need to remove from config/bundle.php right?
thank you for your help
Ok, the bundle you want to remove is this one
symfony/debug-bundle- I recommend not removing it because it only works on the "dev" environment, so your clients won't see it, also, it should be in therequire-devcomposer key and those dependencies should not be installed in your production server. You can do that by adding the flagcomposer install --no-devThat's true only for bundles
Cheers!
Hi MolloKhan,
Thank you.
I applied this command: composer install --no-dev but page gives below error:
Attempted to load class "DebugBundle" from namespace "Symfony\Bundle\DebugBundle".<br />Did you forget a "use" statement for another namespace?because of that, ı added debug again by command composer require debug
When installing composer deps using the
--no-devflag your must run your application on the "prod" environment, otherwise it will try to load dev dependencies but those were not installed, hence, your errorActually, how can we describe prod? Because my project under /var/www/html and it is working as a apache web.
I dont do in localhost.
Because of that, my expectation is when I do this —no-dev command, it should be disabled.
Thank you so much again for your kindly help
I mean the
APP_ENVenvironment variable. That should be set to "prod" - I recommend you to watch this video, it will give you a better idea of Symfony environments https://symfonycasts.com/screencast/symfony-fundamentals/environmentsCheers!
"Houston: no signs of life"
Start the conversation!