You are viewing revision #4 of this wiki article.
This is the latest version of this article.
You may want to see the changes made in this revision.
If you're using a lot of bower and npm assets with Yii 2.0 you might encounter long running composer update
tasks.
Luckily this issue can be avioded with the recently released version 1.2.0
of fxp/composer-asset-plugin
, which can be confiugred to use native git
instead of GitHub REST-API calls.
You can read more about the details in this issue.
TL;dr ¶
To enhance the speed composer you first need to update the asset-plugin
composer global require fxp/composer-asset-plugin:^1.2.0
In your project's composer.json
add the following settings to the extra
section
"extra": {
"asset-vcs-driver-options": {
"github-no-api": true
},
"asset-pattern-skip-version": "(-build|-patch)"
},
Now you are ready to run
composer update -vv
While your very first run might take a while, due to cloning git-repositories, all subsequent updates should be blazingly fast now!
See also Use no-api option of VCS Githhub driver...
Bonus "prestissimo plugin" ¶
To further improve speed you can also install this wonderful plugin, called prestissimo.
Bonus "Docker" ¶
To use this new feature during local Docker (or VM) development, simply link your cache folder into your container (or VM).
php:
image: dmstr/php-yii2:7.0-fpm
volumes:
[...]
- ~/.composer/cache:/root/.composer/cache
Example Docker image with pre-installed plugins & Yii 2.0 runtime
Using asset-packagist ¶
Asset-packagist is a proxy website which exposes npm and bower packages as composer packages. It works way faster and doesn't require any plugins.
update
The "extra.asset-installer-paths" option is deprecated, use the "config.fxp-asset.installer-paths" option The "extra.asset-pattern-skip-version" option is deprecated, use the "config.fxp-asset.pattern-skip-version" option The "extra.asset-vcs-driver-options" option is deprecated, use the "config.fxp-asset.vcs-driver-options" option
In your project's composer.json add the following settings to the config section
"config": { "fxp-asset": { "vcs-driver-options": { "github-no-api": true }, "pattern-skip-version": "(-build|-patch)" } },
For example: yii2
"config": { "process-timeout": 1800, "fxp-asset": { "installer-paths": { "npm-asset-library": "vendor/npm", "bower-asset-library": "vendor/bower" }, "vcs-driver-options": { "github-no-api": true }, "pattern-skip-version": "(-build|-patch)" } },
@BSCheshir
You need to update your config settings, but that's just a notice for now, please open an issue here https://github.com/fxpio/composer-asset-plugin/issues if you think further support/docs are required.
increase disk usage up to 1400%
The best way to development,
but not for any other!
For example for yii2 project (based at https://github.com/bscheshirwork/docker-yii2-app-advanced-rbac / approx same https://github.com/bscheshirwork/docker-yii2-app-advanced)
for this method
for default
p.s.: alpine image for yii2 is interesting.
Increased disk usage
increase disk usage up to 1400%
Yes, because it needs the git repos to quickly read tags. You get this penalty only once for all your projects developed locally.
If you use composer to update in production you should use a
.lock
anyway.composer update / composer install
for all project of this user (who use link to ~/.composer/cache)
its good
yes, IMHO composer install is not use it
size 40k and time ~ 1s8
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.