I actually wrote about this recently in an article about OroCRM, which is based on Symfony 2. If you need some context / why different commands, you might find it interesting.
Symfony has two different systems for including frontend files (javascript, css, images, etc.). First was the assets:install command. This command will look for all Symfony packages in the application for
Resources/public
folder. If found, the assets:install command will copy or symbolic files from Resources/public to web/public/bundle/[bundle-name] . Here, links created using the twig assets function will search for these files. it
<script src="{{ asset('js/script.js') }}" type="text/javascript"></script>
Becomes this
<script src="/bundles/[bundle-name]/js/script.js" type="text/javascript"></script>
What does the assets system do. It allows you to store your interface files along with the package.
The assetic system assetic different. Using assetic you refer to such files.
{% javascripts '@AcmeFooBundle/Resources/public/js/foo.js' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %}
There are similar tags for style sheets and images. Please note that assetic allows you to reference files in any bundle. ( @AcmeFooBundle ). Assetic will also allow you to reference multiple files in a wildcard folder.
{% javascripts '@AcmeFooBundle/Resources/public/js/*' %} <script type="text/javascript" src="{{ asset_url }}"></script> {% endjavascripts %}
Another difference with assetic is the generated links. In a dev environment, they will look something like this.
<script type="text/javascript" src="/app_dev.php/js/foo.js"></script> <script type="text/javascript" src="/app_dev.php/js/bar.js"></script>
That is, requests for these files will be executed through the PHP front-controller ( app_dev.php ) using special configuration of routes in the assetic package. This means that when you are in dev mode, you never need to dump assets. They turn on automatically. It also allows you to apply filters to files. For example, the cssrewrite filter is cssrewrite to file attachments below.
{% stylesheets 'bundles/acme_foo/css/*' filter='cssrewrite' %} <link rel="stylesheet" href="{{ asset_url }}" /> {% endstylesheets %}
If you ever wanted to programmatically change the output of your external components - assetic allows you to do this by writing custom branch filters.
However, this works intensively. In production, instead of linking each file separately through the PHP front controller file, the generated HTML will look like this:
<script type="text/javascript" src="/js/as5s31l.js"></script>
Where as5s31l.js come as5s31l.js ? This is what the assetic:dump command assetic:dump . It combines all the individual javascript / css files (after applying the filters) and creates a nice, static, cached file for production.
What you need to do
Unless otherwise specifically specified in the project, you should always run assets:install and assetic:dump , because you will never know which of your third-party packages use these commands. Before deploying or viewing the application in prod mode, you need to run assetic:dump . The order does not matter.
As for the system your package should use - if you read above and you don't know what assetic can do for you, use assets . You will be well.