2017/05/12

prestissimo for composer

composer 是一個解決 dependency hell 的好工具,但令人詬病的是跑得實在有點慢,特別是 composer update 的時候,搞不好就一直 update 到下班了 ... Orz

所以這裡介紹一個工具:prestissimo。當有多個 packages 需要下載時,prestissimo 會自動跑 multi-process 來下載 depends:
composer install -vvv
.....
Dependency resolution completed in 0.093 seconds
    Prefetch start: total: 27
    1/27:    https://codeload.github.com/sebastianbergmann/php-file-iterator/legacy.zip/3cc8f69b3028d0f96a9078e6295d86e9bf019be5
    2/27:    https://codeload.github.com/sebastianbergmann/code-unit-reverse-lookup/legacy.zip/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18
    3/27:    https://codeload.github.com/sebastianbergmann/php-timer/legacy.zip/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f
    4/27:    https://codeload.github.com/sebastianbergmann/php-text-template/legacy.zip/31f8b717e51d9a2afca6c9f046f5d69fc27c8686
    5/27:    https://codeload.github.com/sebastianbergmann/php-token-stream/legacy.zip/e03f8f67534427a787e21a385a67ec3ca6978ea7
    6/27:    https://codeload.github.com/myclabs/DeepCopy/legacy.zip/8e6e04167378abf1ddb4d3522d8755c5fd90d102
    7/27:    https://codeload.github.com/sebastianbergmann/diff/legacy.zip/13edfd8706462032c2f52b4b862974dd46b71c9e
    8/27:    https://codeload.github.com/sebastianbergmann/version/legacy.zip/99732be0ddb3361e16ad77b68ba41efc8e979019
    9/27:    https://codeload.github.com/sebastianbergmann/object-enumerator/legacy.zip/1311872ac850040a79c3c058bea3e22d0f09cbb7
    10/27:    https://codeload.github.com/phpDocumentor/ReflectionDocBlock/legacy.zip/8331b5efe816ae05461b7ca1e721c01b46bafb3e
    11/27:    https://codeload.github.com/sebastianbergmann/global-state/legacy.zip/bc37d50fea7d017d3d340f230811c9f1d7280af4
    12/27:    https://codeload.github.com/sebastianbergmann/comparator/legacy.zip/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be
    13/27:    https://codeload.github.com/phpspec/prophecy/legacy.zip/93d39f1f7f9326d746203c7c056f300f7f126073
    14/27:    https://codeload.github.com/mockery/mockery/legacy.zip/6fdb61243844dc924071d3404bb23994ea0b6856
    15/27:    https://codeload.github.com/symfony/yaml/legacy.zip/acec26fcf7f3031e094e910b94b002fa53d4e4d6
    16/27:    https://codeload.github.com/sebastianbergmann/php-code-coverage/legacy.zip/ef7b2f56815df854e66ceaee8ebe9393ae36a40d
    17/27:    https://codeload.github.com/sebastianbergmann/phpunit/legacy.zip/69c4f49ff376af2692bad9cebd883d17ebaa98a1
    Finished: success:17, skipped:10, failure:0, total: 27

我的 project 只有 27 個 packages 所以效果沒有很顯著,但若超過 50 個 packages 要抓時,相信你會非常有感覺。

安豬方法很簡單,把他裝成 global 的 composer package:
$ composer global require hirak/prestissimo

安裝完成以後 prestissimo 便會自動開始運作。

若覺得預設值不夠你用,可以到設定檔裡面自己調整需要的參數 (以下應該不是預設值,被我改過一次了):
$ cat ~/.composer/config.json
{
  "config": {
    "prestissimo": {
      "maxConnections": 10,
      "minConnections": 3,
      "pipeline": false,
      "verbose": false,
      "insecure": true,
      "cainfo": "/absolute/path/to/cacert.pem",
      "userAgent": "",
      "privatePackages": []
    }
  }
}

沒有留言:

張貼留言