Reputation: 380
I red different ways to install jquery in a symfony project but what is the best ?
Via Composer
{
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "1.9.1",
"dist": {
"url": "http://code.jquery.com/jquery-1.9.1.js",
"type": "file"
}
}
}
],
"require": {
"jquery/jquery": "1.9.*"
}
}
Via composer with a package
https://packagist.org/packages/components/jquery
Via composer other explanation
http://rigaudie.fr/articles/symfony/mise-a-jour-jquery-dans-symfony-via-composer
{
"require": {
...
"jquery/jquery": "2.*"
},
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "2.1.1",
"source":{
"url":"https://github.com/jquery/jquery.git",
"type":"git",
"reference":"2.1.1"
}
}
}
],
"scripts": {
"pre-install-cmd": "cd vendor/jquery/jquery && npm install -g grunt-cli",
"post-install-cmd": [
...
"cd vendor/jquery/jquery && npm install",
"cd vendor/jquery/jquery && grunt dist:../../../app/Resources/public/js/"
],
"post-update-cmd": [
...
"cd vendor/jquery/jquery && grunt dist:../../../app/Resources/public/js/"
]
},
}
Thank you for your help !
Upvotes: 1
Views: 586
Reputation: 1822
If you can, and if you will have more javascript libraries, Bower is a very good solution.
composer is good for PHP projects, Bower is good for javascripts projects (and jquery is ...)
See http://bower.io/ for more details
You will have to :
install npm
install bower : npm install -g bower
create a bower.json file at the root of your project
{
"name": "myproject",
"dependencies": {
"jquery": "1.10.",
"jquery-ui": "1.10."
}
create a .bower.rc file
{ "directory": "web/vendor", "json": "bower.json" }
install : bower install
Upvotes: 2