In my preveous post I've described how to manage js vendors in symfony2. However that solution is only applicable for version 2.0.x of symfony. In this post I'll describe how to manage js vendors in 2.1.x.
The idea is the same: load js vendors via symfony's standard mechanism (composer). But load into the folder under web directory.
Open your composer.json file and add the following line
Naming repo in such a way will make composer load vendor scripts under
Now all you have to do is add repositories to composer.json:
If this solution looks like a hack to you check out the next solution.
add repositories:
P.S. Don't forget to add
P.P.S. This is how my composer.json looks:
The idea is the same: load js vendors via symfony's standard mechanism (composer). But load into the folder under web directory.
Solution 1. Use ugly names
Again I will use https://github.com/molecule-man/ExtJsListbox.git as an example of js vendor.Open your composer.json file and add the following line
to the"../web/vendor/extjs/ux/listbox": "master"
require
array.Naming repo in such a way will make composer load vendor scripts under
/.../your-symfony-app/web/
directory and therefore this scripts will be exposed to browser.Now all you have to do is add repositories to composer.json:
Now run
php composer.phar update
and check web/vendor
folder if everything loaded ok.If this solution looks like a hack to you check out the next solution.
Solution 2. Use scripts to make symlink
Add lineto the require array of the composer.json file."js-vendors/extjs/ux/listbox": "master"
add repositories:
Then add the following line to "post-update-cmd" array:
After running
php composer.phar update
there will be symlink created in web folder referring to vendor/js-vendors
directory (however under linux only. For windows you will have to use windows' command for creating symlink).P.S. Don't forget to add
web/vendor
into .gitignore
P.P.S. This is how my composer.json looks:
Why not to use target-dir directive inside composer.json?
ReplyDeleteBecause target-tir works only for subfolders of the vendor folder. You just can't specify ../web/something as target-dir. Correct me if I am wrong.
Delete