Documentation

7.2 Loading assets with bower

Integrated takes advantage of the SpBowerBundle for loading assets. You can easily add a Bower package to your application.

Installing bower dependencies

Place your bower.json in the Resources/config/bower directory.

Example MyBundle/Resources/config/bower/bower.json:

1
2
3
4
5
6
7
{
  "name": "your-bundle-name",
  "dependencies":
  {
    "jquery": "~1.8.2"
  }
}

Now run the command app/console sp:bower:install to install all the necessary dependencies in the asset directory under Resources/public. You need to run the assets:install command to place the assets in de web directory.

A recommendation is to always use an exact version number when loading libraries with Bower. Bower does not use a lock file (like Composer does), so you need to specify the exact version to be sure the correct version is installed on production.

Installing bower dependencies

Add external styleheets

{% integrated_stylesheets
    'bundles/app/css/styles.css'
    'bundles/app/css/styles2.css' %}
{% endintegrated_stylesheets %}

Prepend javascript

{% integrated_javascripts mode='prepend'
    'bundles/app/js/script.js' %}
{% endintegrated_javascripts %}