// composer.json
{
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4", // v2.4.2
"doctrine/orm": "~2.2,>=2.2.3", // v2.4.2
"doctrine/doctrine-bundle": "~1.2", // v1.2.0
"twig/extensions": "~1.0", // v1.0.1
"symfony/assetic-bundle": "~2.3", // v2.3.0
"symfony/swiftmailer-bundle": "~2.3", // v2.3.5
"symfony/monolog-bundle": "~2.4", // v2.5.0
"sensio/distribution-bundle": "~2.3", // v2.3.4
"sensio/framework-extra-bundle": "~3.0", // v3.0.0
"sensio/generator-bundle": "~2.3", // v2.3.4
"incenteev/composer-parameter-handler": "~2.0", // v2.1.0
"doctrine/doctrine-fixtures-bundle": "~2.2.0", // v2.2.0
"ircmaxell/password-compat": "~1.0.3", // 1.0.3
"phpunit/phpunit": "~4.1", // 4.1.0
"stof/doctrine-extensions-bundle": "~1.1.0" // v1.1.0
}
}
Welcome back for part 4 of our Starting in Symfony2 series! We've got some really important topics planned and we're going to start with mastering assets and the Assetic library. We'll bust cache, minimize our CSS & JS files and get you ready to do just about anything with your static assets. We'll also dive much deeper into form rendering - customizing our forms to work with Twitter Bootstrap and learning a lot more about the powerful and advanced mechanisms behind form theming. Finally, we'll cover deployment: what steps are always necessary and some options for automating the process. Let's do this!
Highlights:
thanks for the quality screen casts.
I really wish that you create more screencasts related to the awesome symfony2 framework.
I am interested to see a railscasts sort of thing for symfony which actually covers how to achieve/solve a specific task .
example: .
* using backbone in symfony2
* covering third party bundles like RestBundle ,etc
regards
Before running the "php composer.phar install" don't forget to enable the PHP Internationalization Extension.
I've added a note to look into this. Technically, Symfony shouldn't require the PHP Intl extension, though in practice it causes problems when you don't have this. I'll see if we can clarify this and then add some notes in some spots that should help out.
Cheers!
Finally episode 4. What a great Xmas present.
I hope you keep up the good work. I am looking forward to more episodes, preferably shorter and one-topic episodes.
Hey there, great tutorials!
Finally I made it, I give em 10/10
I would like to know where should we go after completing this 4 episodes ?
Congrats! And thanks :).
Where to go? I have a few suggestions:
1) Build something! This will of course create more questions
2) Go through our Symfony Journey Screencast - it's all about mastering what's under the surface: https://knpuniversity.com/s... (and there will be a few more added to this series). Also, check out the Symfony tag for anything else you haven't seen - we'll always be adding more: https://knpuniversity.com/s...
3) Checkout the Symfony Cookbook page and see what topics interest you - these are like blog posts aimed at specific topics: http://symfony.com/doc/curr...
If you have any other thoughts or ways we can be helpful at this stage, I'd love to hear them. It's been fun interacting with you along the way :).
Cheers!
Hey! cool episode.. I was really enjoy..
I have some question:
what is the right way to add an "assetic object"(css/js file) by sub template(in the bundle view)?
Hi Almog!
To do that, you use the stylesheet or javascript tag exactly the same way as you normally use it in the base template. If you have 1 stylesheet tag in the base template and one in a child/sub template, they do not somehow mix - the end user will download 2 CSS files - 1 representing the combined files from the base template and 1 representing the combined files from the subtemplate. In other words, you add assetic CSS/JS to a child template simply by overriding the "stylesheets" or "javascripts" block and including an Assetic stylesheet or javascript tag, just like normal. Assetic now sees 2 stylesheet tags - one from each template - there's no magic mixing :).
Thanks!
Cool! thanks..
Do you know about third-party bundle who can merge they all into a one file, or maybe it avilable as theme system?
Also I would really like to know about some recommended bundles who handle issues like this(in other words- common recomended bundles)..
Thanks a lot!
~ AlmogBaku
Hi there!
We have no plans to, but I would love to hear what you like about udemy that you would like to see with our content!
Thanks!
I think, the ExceptionController implementation in the source is not compatible with symfony versions >= 2.2.
Current composer.lock has symfony 2.3.1
And hi again Nikos!
Yes, the downloaded code was out of date, which I've fixed at https://github.com/knpunive... and deployed. The script *is* correct with code that works for Symfony 2.2 and higher. The screencast still shows the old code, but with a note to see the script on the site for the updated details. The idea is all still the same, but some function arguments changed in 2.2.
And thanks for pointing this out as well :)
Hi Nikos!
You're right! The screencast had the correct paths, but the script on the site had a typo. I've fixed it at https://github.com/knpunive... and deployed it to the site.
Thanks for pointing that out!
Hi Ryan! Can be included on this course or maded a new separate screencast about field collections? http://symfony.com/doc/curr...
Hey!
We could! But I'll ask you first about this cookbook entry - http://symfony.com/doc/curr... - have you found it useful? Are you trying to do something that this doesn't cover?
Thanks!
The documentation in the Symfony website for sure is good. But I found this as an interesting topic to create a screencast that will accomplish more the huge topic of forms in symfony2. Also I have learned more Symfony2 watching your videos than reading the official documentation. I like more video tutorials to listen and see how is done :)
That's really nice to hear and great feedback! We've been thinking about potentially making smaller, more focused tutorials (this would be a great example). The challenge is that our model is a per-video price, and I'm not sure if that works as well with smaller videos.
Thanks!
Maybe you can create a new set of Q&A screencast for this year with more tutorials on advanced topics. Will be waiting for them, thanks!
I bought all your videos, they are incredibly helpful.
I have been struggling with some design concepts and placement of business logic. Trying to keep controllers thin, entities pure, repositories "queryized" only left unorganized DI classes. Then I saw ModelManagers and it clicked. This blog has the general idea, but I bet you guys could explain it crazy or go to the next level (and another video) http://problematic.io/2012/...
Anyway, just a thought and thank you!
Hello Ryan & KNPTeam,
I have a question this time related on the installation of uglifycss.
I'm running this project on Windows8, I've installed uglifycss successfully using the following command: npm install uglifycss --save...It worked, but it didn't install the Folder .bin/uglifycss and its binary file inside....The fact is that It broke the styles as the root on the config.yml is not correct.
(
uglifycss:
bin: %kernel.root_dir%/../node_modules/.bin/uglifycss
)
I've been reading on the Cookbook and it suggested another way of installation using this command: npm install -g uglifycss, I did it and it installed a folder with name "g" and some other files.....Is there a way to get this .bin/uglifycss binary file from other way, or should I do extrawork somewhere??
No Iddea....
Thanks and Keep in touch!
Hey Edison!
Hmm, the "npm install uglifycss --save" *should* have created 2 things:
1) a node_modules/uglifycss directory
2) A node_module/.bin/uglifycss file
*However*, I forgot before that these files in node_modules/.bin are created via symbolic links, so I don't know how this will work on windows. Quite possibly, these files will not be there. BUT, that's totally fine - they are just there for convenience. You should be able to point directly at node_module/uglifycss/uglifycss.
Let me know if that path exists - that's the *true* uglify binary file.
Cheers!
for bootstrap the class for the fields to highlight when there's an error is 'has-error' now instead of just 'error'. submitted a pull request :)
Thanks Thomas! The "has-error" is correct for Bootstrap 3 and the "error" is correct for Bootstrap 2, which we use in the screencast. Either way, it's a good note, and when we update the recording, we'll update the class names as well :).
Thanks!
Hi there, very much enjoying this episode,
I've got a problem with integrating bootstrap.
I've extracted the bootstrap dir to EventBundle/public/css/
The bootstrap directory and files are there as in the video, but for some reason, Assetic says:
[error] The source file "D:/Ampps/www/s2.starwarsevents.local/app/../web/bundles/event/css/bootstrap/css/bootstrap.css" does not exist.
also in PHPStorm it's marking 'bundles/event/css/bootstrap/css/bootstrap.css' in base.html.twig as 'missing asset'
I tried the `Invalidate Cache / restart` command from PHPStorm, and the `missing asset` error disappears once PHPstorm restarts.
But as soon as i run the `assetic:dump --watch --force` command it generates the same error and the `missing asset` appears in phpstorm again, any ideas as what could be amiss here?
Hey!
Hmm, first, make sure you're "installing the assets", which creates the symlink (or copy if you're on Windows) from web/bundles/even to src/Yoda/EventBundle/Resources/public:
php app/console assets:install --symlink
(leave the --symlink off if you're in Windows). Without this, web/bundles/event isn't a valid path (and should cause the error!).
Whether this is the problem or not, I'd actually open up the web/bundles/event directory in PHPStorm and make sure that the path (e.g. bundles/event/css/bootstrap/css/bootstrap.css) exists and is exactly correct.
Let me know what you find out! :)
Thanks Ryan, yes the problem was that i had not installed the assets, it wasn't mentioned in the video, to re-run that after adding bootstrap, now you say it it seems obvious!
something i need to remember!
Awesome! It all depends on whether or not you last installed the assets with a symlink or a copy. If you did it via a symlink, then you're good forever (you can add new stuff and it's just there). If it's via a copy, then you have to re-install. We do show using symlink in the video, BUT, by default, when you run "php composer.phar install", it runs assets:install for you, but uses the "copy" option (not symlink). So, you might have it symlinked at first, then composer changes it to a copy. Kind of a gotcha - something I'm hoping we'll improve in Symfony's core.
Cheers!
Hello Ryan & Leanna,
and thank you for those videos, they've been very helpful!
Can you make a video about SonataAdminBundle?
Have a great weekend! :)