Boost composer-asset-plugin update speed

You are viewing revision #2 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#3) »

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)"
},

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