Max Damage Max Damage - 1 year ago 135
Javascript Question

Using jQuery UI in Symfony2 through Composer. How do I publish assets from vendors directory?

In a Symfony 2.3 project I want to install jQuery UI using Composer. I found the package

available on

The project is also using BraincraftedBootstrapBundle that loads jQuery (see Getting Started).

I have 2 problems with this configuration:

  1. I have no idea how to access in my Twig tempaltes the jQuery UI files that are located in

  2. How can I tell Composer that I don't want jQuery UI to require it's dependency
    , since jQuery library is already installed by BraincraftedBootstrapBundle, under
    or to tell BraincraftedBootstrapBundle to use jQuery from

composer show -i | grep jquery
brings up this:

components/jquery 2.1.3 jQuery JavaScript Library
components/jqueryui 1.11.4 jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. W...
jquery/jquery 1.11.2

Answer Source

There are multiple ways of doing this:

  1. you can define the vendor path for the file in your config.yml. files stay in the vendor folder.

  2. you can also define a components-dir (custom config directive for "components"):

        "require": {
            "components/jquery":     "^2.0",
            "components/jqueryui":   "^1.11"
        "config": {
            "component-dir": "web/assets"
  3. or you can trigger a custom install command and move the asset files from the vendor folder to your assets folder and then define this asset path.

  4. or you can use bower, executed as a postinstall command, to fetch and install the assets into a defined dir.