Chapters
18 Chapters
|
1:50:35
|
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!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.3.0 || ^8.0.0",
"ext-ctype": "*",
"ext-iconv": "*",
"easycorp/easy-log-handler": "^1.0.7", // v1.0.9
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"symfony/asset": "5.0.*", // v5.0.11
"symfony/console": "5.0.*", // v5.0.11
"symfony/debug-bundle": "5.0.*", // v5.0.11
"symfony/dotenv": "5.0.*", // v5.0.11
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.0.*", // v5.0.11
"symfony/monolog-bundle": "^3.0", // v3.5.0
"symfony/profiler-pack": "*", // v1.0.5
"symfony/routing": "5.1.*", // v5.1.11
"symfony/twig-pack": "^1.0", // v1.0.1
"symfony/var-dumper": "5.0.*", // v5.0.11
"symfony/webpack-encore-bundle": "^1.7", // v1.8.0
"symfony/yaml": "5.0.*" // v5.0.11
},
"require-dev": {
"symfony/profiler-pack": "^1.0" // v1.0.5
}
}
31 Comments
Hi I'm not seeing any info logs in the profiler although I can see the 'voting up' and 'voting down' logs in the log file in the var directory. As far as I can see monolog.yaml has config for debug level in dev. Any ideas? (Symfony 5.4)
I see, you have to look at the profiler for the correct route i.e. the ajax requests.
I don't know if I've missed something, but I had to add in the public directory a build folder including manifest.json with a path to the css files for the asset to work.
Hey Matěj V.!
Hmmm, that's interesting! That should not be required. The manifest.json file that you're referring to comes if you use Webpack Encore in Symfony, which is a great library, but one that we're not using at this moment in the tutorial (we do add it later on). When you use Encore, it creates a public/build/manifest.json file (among other files) that contains a map of "source filename" => "final filename" for all the things it builds.
But out of the box, Symfony doesn't look for this file. It only starts looking for it once you have Encore installed. More accurately, when you install Encore, its recipe adds a configuration file that activates this: https://github.com/symfony/recipes/blob/master/symfony/webpack-encore-bundle/1.9/config/packages/assets.yaml
The tl;dr is this: I think that somehow you have this
json_manifest_pathconfig already in your app... which normally comes when you install Encore. If you DO have this, but don't have Encore installed, then delete it. If you have this because you DID install Encore, then you can use Encore to build your assets, including this manifest.json file :).Cheers!
Thank you for answer and mainly for this great course, It's one of the clearest guides on Symfony or anything programming wise that I've seen so far, while along being really positive! :)
And yeah I think I've copied the libraries that are used in this tutorial in the versions tab right away on start of the course, so it just got confused that the file wasn't present.
We're happy to know you are liking our content. Cheers!
Hi, I have set up everything as the tutorial says. But somehow when I paste in the new 'show.html.twig' code and refresh, the page loads and loads until it crashes and says 'unable to fetch the response from the backend: unexpected EOF'.
In Terminal it says that it matched the route, but than it gives the ERROR from above and it says: maximum execution time of 30 seconds exceeded in /vendor/twig/twig/src/Extension/ProfilerExtension.php on line 33.
What to do?
EDIT: I found the problem already. I accidentally pasted the show.html.twig in the base.html.twig file.... dumb! :P
Hey Paulus D.
No worries, it happens. As a tip, when weird things happens, sometimes clearing the cache or restarting the web server helps.
Cheers!
Hi, i tried to to put in public my css called style.css but idk it doesn't work. If i rename the file app.css it works but i cannot rename all file that i need. How can i solve this? thanks
Hey Alessandro,
OK, as far as I understand you moved style.css file to public/ folder, right? Then, in the template you should be able to link it as:
But if you moved that css file to a subfolder e.g. public/css/ - then you would need to reflect that subdirectory in the path:
Also, make sure you haven't started the project from a subfolder, otherwise it still may fail loading. The asset() Twig function that we will show in this video would help with this:
But make sure to write the correct path there that's related to the public/ folder.
I hope this helps!
Cheers!
I havent the autocompletion for the "asset" term. Can someone help me. Ho do i get it because i already installed the twig plugin for phpstorm
Hey Duncan W.
A few Twig functions just don't work but in this case it should. Have you the Symfony Support plugin installed and enabled too?
Hi there,
I have a question about the
asset-function - cite: <blockquote>So why are we bothering to use a function that does nothing? Well, itdoes do two things... which you may or may not care about. First, if you decide to deploy your app to a subdirectory of a domain - like ILikeMagic.com/cauldron_overflow, the asset() function will automatically prefix all the paths with /cauldron_overflow. Super great... if you care</blockquote>".
My hosting service wants me to deploy to a subdirectory of document root. Apache finds
index.phpbecause of a redirect statement in.htaccess. How do I tell theasset-function to prefix the paths with 'public'?Hey Georg,
Do you use the Symfony's official .htaccess? You can get it by installing "symfony/apache-pack", it has a recipe that will bring this .htaccess into your project: https://github.com/symfony/recipes-contrib/blob/master/symfony/apache-pack/1.0/public/.htaccess
I suppose this .htaccess should help. If not, probably take a look at the redirect statement you have and try to create a similar for assets. Unfortunately, I can't help with it.
But in case you want to prefix all your assets with "public/" - you can do it via:
You can make it for a specific env, e.g. do it only for prod - then add it in "config/packages/prod/asset.yaml" only. Or you can base it on env var, then you can set it to empty string locally and to "public/" on production.
Cheers!
Hey Victor,
Yes I use .htaccess from "symfony/apache-pack". I'll try to adjust it for '/css, /images' etc. It's good to know that there is a quite elegant fallback by editing the config file(s).
Thanks a lot!
Hey Georg,
In case you didn't add any custom redirects to your .htaccess - I'd suppose it just should work out of the box. If you did - then yeah, you have to adjust it for your assets as well. But yeah, as you said, you have a fallback option thanks to assets() Twig function ;)
Good luck with adjusting .htaccess! :)
Cheers!
Not sure how the tutorial folder got into the cauldron_overflow project? :)
It MAY have snuck in there after a few chapters were already recorded 😀- you have a good eye for detail! It's definitely in the code download, though ;).
Thanks, bro ! :D
Hi! Can you please tell how did you get that à in voilà? Was it some shortcut in PHPStorm or it's just from Mac?
Hey Alexey,
Yes, this is the recent upgrade of Mac OS I suppose. If you press and hold the keyboard letter button for a second or two, e.g. "a" - it will show additional chars for that letter and you can choose from the list. I suppose it might be available on other OS, but I'm not sure how to do it, better google for it if you really need this feature.
Cheers!
I have a problem with this asset autocomplete option. I use PHPStorm and have Twig Plugin enabled. But if I type asset into the "" I only have some angular functions but not from Twig. I must write {{}} and if i type asset into this brackets i've got a autocomplete option. Do you know maybe what is the problem? I don't have any of this autocomplete functions like you shown (asset, asseticjs or asseticcss). Thanks for help.
Hey Łukasz,
Do you have Symfony Plugin installed and enabled in your PhpStorm? I suppose that autocompletion for "asset()" Twig function works thanks to that plugin. You need to install it first, then go to its configuration and enable it. Also, check that paths are correct. For example, the path to the web directory should be "public/". Then, after you enabled it and made necessary config tweaks inside - restart your PhpStorm just in case and try again.
I hope this helps!
Cheers!
Ok I know what is wrong. If you want to use that shortcuts you must install Live Templates from this link: https://github.com/knpunive.... If you do everything like it's said there, you should have this autocompletion asset thing. So you have it installed on your version of PHPStorm but didn't said about it :P
Hey Łukasz,
Oh, now I see you were talking about live templates, it's not actually an autocompletion :) Anyway, glad you figured out how to get it working yourself, good job!
Cheers!
I did everything like you said (install and enable Symfony plugin, configure it to public directory and restart PHPStorm), but nothing happens. This autocomplete only works after I write {{}} and inside it type asset. But if I wrote asset only inside "" it does nothing.
Do you have another autocomplete plugin (like Tabnine ?)
After remove it, I was able to autocomplete {{ asset("image/tisha.png" }} with just "tisha" and then hit tab.
Hey Tesdy14,
Thanks for this tip! Yeah, other plugins really may cause incompatibility problems sometimes.
Cheers!
Hey Łukasz,
Ah, yes, sure, it will only work in curly braces {{}} - this is how PhpStorm knows when you actually call that asset() function. Otherwise, it won't autocomplete because, well, the syntax is incorrect.
Cheers!
Hello !! How do we get the css code ?
Hey @Dean
The CSS file comes with the course code inside the
tutorialdirectory. You just need to download it from this page, at the right top corner it's the button :)Cheers!
"Houston: no signs of life"
Start the conversation!