Where should assets be stored in a Symfony project?

592 views Asked by At

The "Official Symfony Best Practices" states:

Symfony developers have traditionally stored these assets in the Resources/public/ directory of each bundle.

and mentions as "Best Practice":

Store your assets in the web/ directory.

So we can understand that unless before, when assets was stored in bundles, we have now to store them in web/.

But are we talking about source files or complied/minified files?

A little later in the text, the documentation rightly points out:

Keep in mind that web/ is a public directory and that anything stored here will be publicly accessible. For that reason, you should put your compiled web assets here, but not their source files (e.g. SASS files).

So, my questions:

1) Should we still store the assets source files (not compiled/minimized) in bundles? If yes, where?

2) Is the Resources/public directory really publicly accessible or just accessible by Assetic to minify and copy assets to web/?

The chapter "How to Use Assetic for Asset Management" states:

But with Assetic, you can manipulate these assets however you want (or load them from anywhere) before serving them.

3) So, is the Resources/public directory still relevant?

4) Why use a public folder like in this example:

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

if Assetic would be able to read files from AppBundle/Resources/assets/js?

5) About source files related to all bundles, where to put them? It seems even the Symfony team wondered about that.

0

There are 0 answers