0

I would create a CoreBundle, and use this for your template layout, base template, etc.. and do your includes there.

Furthermore if you leave it in the app/Resources making a new directory for Public/css to my knowledge it wont get pulled down when you install/dump your assets to the /Web directory. So if by chance you happen to be only using those files on your live production server, and or like to use that directory as your normal include path, then it just makes more sense.

Also, for me, i use less, and the less files arent compiling and shipping the compiled version into the /web folder either.

If you make a core bundle, you can have all this natively, and have your files in an area that your more likely to be used to getting into with your file editors.

It also helps separate custom files away from the core framework better.

As a sidenote, i did like fsehat's suggestion, however i was a bit disappointed when the assets werent being handled properly. also i dont like using ../ in include paths, ./ is ok, but not ../

if you put them in a bundle (/Your/Bundle/Public/css), after compiling, you can just call them from your templates like this for e.g. <link href="{{ asset('/css/loader.css') }}" rel="stylesheet" media="screen">

Jon Miles
  • 9,605
  • 11
  • 46
  • 66
blamb
  • 4,220
  • 4
  • 32
  • 50

3 Answers3

1

Possible dublicate of Symfony 2 - Working with assets.

For example, You need to store your styles in src/YourBundle/Resources/public/css

Use next command for assets CSS

php app/console assets:install web

Styles will be copy to web/bundles/YourBundle/css dir. And now you can asset them easy in templates

Community
  • 1
  • 1
Victor Bocharsky
  • 11,930
  • 13
  • 58
  • 91
0

Put your css js in web folder like directory

C:\wamp\www\yourProject\web\bundles\acmedemo\css\

And use it using

<link rel="stylesheet" href="{{ asset('bundles/acmedemo/css/mystyle.css') }}" type="text/css" />
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112
0

Sure, You will share your javascripts and stylesheets between your bundles, you need to visit following URL and follow the step:

With Assetic / Twig / Symfony2, can I define front end libraries?

Symfony2: How to share js libs and css between bundles

Community
  • 1
  • 1