Chapters
21 Chapters
|
2:23:48
|
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": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/asset": "6.0.*", // v6.0.3
"symfony/console": "6.0.*", // v6.0.3
"symfony/dotenv": "6.0.*", // v6.0.3
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.0.*", // v6.0.4
"symfony/monolog-bundle": "^3.0", // v3.7.1
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.0.*", // v6.0.3
"symfony/ux-turbo": "^2.0", // v2.0.1
"symfony/webpack-encore-bundle": "^1.13", // v1.13.2
"symfony/yaml": "6.0.*", // v6.0.3
"twig/extra-bundle": "^2.12|^3.0", // v3.3.8
"twig/twig": "^2.12|^3.0" // v3.3.8
},
"require-dev": {
"symfony/debug-bundle": "6.0.*", // v6.0.3
"symfony/stopwatch": "6.0.*", // v6.0.3
"symfony/web-profiler-bundle": "6.0.*" // v6.0.3
}
}
16 Comments
For who can not install node js moduls , change Symfony lock file Encore to v:2 , and composer req encore and composer require symfony/stimulus-bundle , after that npm install or yarn install . And read composer error feedbacks i will help you very strong.
maybe it will help someone to future :)
Hey Doston,
Thanks for this tip! We're using symfony/webpack-encore-bundle v1 in this course, v2 may slightly differ from what we're showing in videos.
Also, if you even have any problems following our tutorials - feel free to ask for a help in the comments section and our support team will help you.
Cheers!
What? Webpack, seriously?!
Webpack has nothing to do with writing professional CSS and JavaScript, and stating so just confuses a user about what webpack is. So, before webpack we didn't write professional CSS & JavaScript? When your audience is this large you need an editor, someone who will tell you to stop talking lala!
I don't use webpack because unless you understand webpack strategies, you'll end up loading JS and CSS files for pages that don't even use them. Or worse still, you'll end up loading ALL you CSS and JS on every page load.
Do yourself a favor, write 3 functions: injectCSS, injectJS, and injectFiles. Use the first 2 to store references to files you need and call them from functions or controller constructors. The last method gets called before your page is rendered and puts the files where they need to be, wrapped in the correct loader tags...you will only ever load the files you need when you need them.
Webpack is used by people who drives cars both don't know how to change the oil...get under the hood and learn something.
Hey @Digital-Pig!
You are totally right! This tutorial is a few years old now, which is why it includes Encore. In our Symfony 7 tutorial, we use AssetMapper: a way to be able to write modern JavaScript with zero build system. A refreshing "back to basics", for sure.
I hope that gives you some context about why Webpack was included here a few years ago: it was (debatably) a necessary evil. And now we've gotten rid of it! 🥳
Cheers!
Hi guys,
I set up a starter project using bootstrap and 1 file scss (app.scss)Then any time I changed app.scss, the
yarn run dev-servertake too much long, about 3.8 ~ 4 second for compiling.Then, I realize that, if I remove the
@import "~bootstrap/scss/bootstrap";now is fast.Or, if I change app.scss to app.css and
@import "~bootstrap, it's also fast, just about 100 ms.So, shortly say:
Here is my app.scss:
Is there any one face the same issue? I don't know where this problem came from, my webpack.config.js have .enableSassLoader() and there's nothing special with it.
Hi @Dang,
Honestly it's not a problem, you just compiling complete Bootstrap library which is pretty massive inside. So lets check your examples one by one
Basically if you want to use scss bootstrap you need to include only what you really need so it can be compiled faster and be lighter =)
Cheers!
Hi @sadikoff,
Thank you for pointing out the reason. I did change my app.scss to import the bootstrap css instead.
@import "~bootstrap/dist/css/bootstrap.min.css";. Webpack not compile the bootstrap so it's fast as expected. Then, I tried your method to import only some parts bootstrap scss that the page need. It works and reduce the time, but still. Because to make that simple page works as before, I have also to import many modules such as functions, variables, form, button, container ... And with hot reload, the latency still not make me happy :)).So I would like to know if there are a way in Webpack, we can ignore the compile process for bootstrap scss? Or maybe compiling it only one time with cache ... ?
Sorry, but the only way to ignore bootstrap compiling is using precompiled css file. However IIRC webpack should have internal cache to speedup process, but I can't say if it works properly with bootstrap.
So as for me the only solution is for example on active development stage if you don't need to modify bootstrap styles is to use precompiled bootstrap css file
Cheers!
Can't get past a yarn watch error.
package.json
Errors are:
If I manually add @babel then I get
when I use the composer require I get the following:
composer require encoreHey Joet,
Hm, it sounds like you have problems with the Composer setup on your laptop. I bet you cannot install any Composer package, not only "encore", right? Could you try to install something else and confirm that you see the same error?
I think you should try to upgrade your Composer to the latest first. Then probably try to run "composer diagnose" to check the system and of everything is ok - try install that package again.
Cheers!
It didn't work for me, I'm using yarn v. 1.22.15 but I got the next message after calling both npm run watch or yarn watch:
Error: Encore.isRuntimeEnvironmentConfigured is not a recognized property or method.
Hey daniel,
That's odd. did you install
@symfony/webpack-encore, double-check that your package.json and composer.json files matches to the tutorial's. If you debug theEncorevariable inside yourwebpack.config.jsfile, what do you get?Cheers!
Sorry, very very new to all of this, how does one debug the Encore variable?
Hey @Antirixas
Inside your
webpack.configfile, writeconsole.log(Encore.isProduction()to see if it's running in production mode, or, you can print the whole config like thisconsole.log(Encore.getWebpackConfig(). You need to run webpack after each changeCheers!
It didn't worked for me: I got the next message when executing yarn watch:
`Error: Encore.isRuntimeEnvironmentConfigured is not a recognized property or method`.
"Houston: no signs of life"
Start the conversation!