Skip to content

Instantly share code, notes, and snippets.

@macagua
Last active October 29, 2020 13:15
Show Gist options
  • Save macagua/d85f8790dba9c0ad2745926937b2d240 to your computer and use it in GitHub Desktop.
Save macagua/d85f8790dba9c0ad2745926937b2d240 to your computer and use it in GitHub Desktop.
Install a Bower package with Composer configuration for Yii2 project

Install Bower packages with Composer configuration for Yii2 project

Install two (02) Bower packages like jquery 2.2.4 and pickadate 3.5.6 with Composer configuration for Yii2 project

Installing Composer

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

Installing Bower

$ sudo npm install -g bower

Development Installation

For install the Webapp in Development enviroment executes the following commands:

$ composer global require "fxp/composer-asset-plugin:~1.1.1"
$ composer install

Later when finish the installation, you will have a new directory called vendor/ based on composer tool. This directory have a directory called bower that includes the Bower packages needed for your project.

jQuery 2.2.4 Bower package look like the following:

vendor/bower/jquery
├── AUTHORS.txt
├── bower.json
├── dist
├── external
├── LICENSE.txt
├── README.md
└── src

Pickadate 3.5.6 Bower package look like the following:

vendor/bower/pickadate/
├── bower.json
├── Gruntfile.js
├── lib
├── package.json
├── tests
├── version-bump.js
└── version-commit.js
{
"name": "application",
"description": "your application description Bower package.",
"keywords": [
"your",
"application",
"description"
],
"authors": {
"name": "Leonardo J. Caballero G.",
"email": "[email protected]",
"homepage": "https://github.com/macagua"
},
"homepage": "https://github.com/your-organization/your-repo",
"repository": {
"type": "git",
"url": "https://github.com/your-organization/your-repo.git"
},
"dependencies": {
"jquery": "2.2.4",
"pickadate": "3.5.6"
}
}
{
"name": "project/application",
"description": "your application description Composer package.",
"keywords": ["your", "application", "description"],
"homepage": "https://github.com/your-organization/your-repo",
"type": "project",
"license": "proprietary",
"support": {
"issues": "https://github.com/your-organization/your-repo/issues",
"wiki": "https://github.com/your-organization/your-repo/wiki",
"source": "https://github.com/your-organization/your-repo",
"email": "[email protected]"
},
"minimum-stability": "dev",
"authors": [
{
"name": "Leonardo J. Caballero G.",
"email": "[email protected]",
"homepage": "https://github.com/macagua",
"role": "Developer"
}
],
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "=2.0.7",
"yiisoft/yii2-bootstrap": "2.0.5",
"yiisoft/yii2-swiftmailer": "2.0.4",
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*"
},
"config": {
"process-timeout": 1800,
"secure-http": false
},
"scripts": {
"post-create-project-cmd": [
"yii\\composer\\Installer::postCreateProject"
],
"post-install-cmd": [
"bower install"
],
"post-update-cmd": [
"bower install"
]
},
"extra": {
"branch-alias": {
"dev-master": "master-dev"
},
"yii\\composer\\Installer::postCreateProject": {
"setPermission": [
{
"runtime": "0777",
"web/assets": "0777",
"web/uploads": "0777",
"yii": "0755"
}
],
"generateCookieValidationKey": [
"config/web.php"
]
},
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
@abdurahmanadilovic
Copy link

Actually, there is a simple solution now using https://asset-packagist.org/. YII is using it by default in the newer versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment