3

Recently I deployed some projects like trntv/yii2-starter-kit and so on.but all applications are publishing assets on '@vendor/bower' instead of'@vendor/bower/bower-asset'. I have read the question Yii2 Composer manage package in bower and bower-vendor and solved it . but I still feel confused about the directory vendor/bower/bower-asset.
What's the part does bower/bower-asset play in php application? it is not a composer package but many theme store in there. Furthermore, bower is a dependency management for javascript just like Composer for PHP , but how does it solve dependency for js package by PHP on this occasion that I have not install node.js environment?

1 Answer 1

2

The idea of Composer Asset Plugin is to download Bower / NPM packages and manage their dependencies without having Node JS, Bower and NPM installed (through PHP / Composer). Also it adds possibility to add JavaScript dependencies for PHP packages that use JavaScript libraries.

See for example yii2-bootstrap Yii2 extension (PHP) has a dependency on Bootstrap (JS + CSS):

"bower-asset/bootstrap": "3.3.* | 3.2.* | 3.1.*"

When you run composer install or composer update, all JS dependencies will be installed to vendor/bower folder.

This is built into the core, but very ambiguous, receives a lot of criticism and there are plans to remove it in 2.1.0 (as far as I remember, it was included before release of 2.0 even it was unstable). Unfortunately this is required and there is no normal way to disable it.

You can read more info on the extension's Github page.

As for folder name, it should be named bower, not bower-asset, if you installed everything correctly.

It's named like so automatically, make sure you have the latest version of plugin:

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

I'd recommend to even switch to:

composer global require "fxp/composer-asset-plugin:*"

If you have problems or errors, execute:

composer global remove "fxp/composer-asset-plugin"

Then reinstall it again, delete vendor and composer.lock in your application folder and run:

composer install

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.