2

Maybe I don't understand it. My main template is: app/Resources/view... But where should be css/js/img ? In my opinion in: app/Resources/view/public/... Because it isn't files bundles and all project in production environment. In my case "frontend page".

Of course, when the files(css/js/img) belongs to bundle is in appropriate bundle.

Now I have:

{% stylesheets '../app/Resources/views/public/css/*' %}
            <link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}

Assetic Add file located in app/Resources/js

But don't see images files.

How according to the standard symony2, I should store and manage "main" template files?

I would like to safely and well. I learn the symfony2.

Community
  • 1
  • 1
viko
  • 491
  • 6
  • 23
  • I suppose to place all your asset files in 'web' folder instead of Application scope directories as many developers do. – Tuan nguyen Apr 07 '15 at 10:10

2 Answers2

1

All "web assets resources" should be place into web folder (that is made for all files "reachable" from the www).

You only need to run php app/consolle assets:install(*) to let symfony place all of your assets in the right place

When you want to use them simply use

<link href="{{ asset('bundles/yourbundlename/css/style.css') }}" type="text/css" rel="stylesheet">

(or whatever you have called your files)

(*) you can choose even the --symlink option to avoid file copies

DonCallisto
  • 29,419
  • 9
  • 72
  • 100
  • I know `asset('bundles/yourbundlename/css/style.css')`, but I don't want use bundle from "main frontend" template. You suggest that I should create bundle (FrontendBundle) or user directory /web ? It seems to me that the web is ugly :( – viko Apr 07 '15 at 10:35
  • @viko: Sincerly I don't know because I've never experienced this need. One think that I can suggest is to create inside "web/bundle" a folder (i.e.: "common" where to place all resources that aren't related to a particular bundle) or you can create a brand-new common bundle that will share not only resources but even code from bundle to bundle (if you need). I don't know if it is the best practice however... – DonCallisto Apr 07 '15 at 10:39
1

All the images CSS js file should be kept in /web folder and can be used

  {% stylesheets '/css/*' %}
        <link href="/abc.css" type="text/css" rel="stylesheet" />
  {% endstylesheets %}

or should be kept in bundle and you have to assetic dump them.

      {% javascripts '@AppBundle/Resources/public/js/*' %}
      <script src="{{ asset_url }}"></script>
      {% endjavascripts %}

kindly refer the below link for the same:

http://symfony.com/doc/current/cookbook/assetic/apply_to_option.html

kailash sharma
  • 356
  • 1
  • 12