How to include bundle assets (CSS & JS) in Symfony2 base template?
01:22 28 Aug 2013

Background:

I am creating my first applications in Symfony and have encountered a problem that I can't seem to get past. Going forward the application that I'm creating will be the template which I will copy to create my next application - so the more in the global configuration the better from my perspective.

The question: Ideally I want my base.html.twig file to include a /css/style.css and /js/scripts.js from the Resources/public folder in the specific bundle being used. How do I do this? (Code snippets please!)

I have tried many other ways (guessing that the above wasn't possible) including block inheritance / overwriting and that has worked for the stylesheet (albeit I have to hard code the bundle name into the dependency name, which sucks).

The plan with this application is that I should be able to clone it under a new name and get going straight away, minimizing how much find & replace I have to do.

Thank you!

symfony twig assetic symfony2