Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

光遅い問題に対応して Composer を100倍速くする

More than 3 years have passed since last update.

とりあえずコピペ

Composer 本体のインストール

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

リポジトリ変更と高速化プラグインのインストール

composer config -g repos.packagist composer https://packagist.jp && composer global require hirak/prestissimo

Composer は遅い

https://speakerdeck.com/hirak/composer-keynote

  • packagist.org および github.com がネットワーク的に遠い
  • file_get_contents + https ストリームラッパー
  • 毎回コネクションを作り直す
  • 通信回数が無駄に多い
    • packagist.org の json ダウンロード
      • HTTPS 4往復
      • HTTP 2往復×(8往復×パッケージ数)
    • github.com の zip ダウンロード
      • HTTPS リダイレクト 8往復×パッケージ数

Composer のインストール

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

リポジトリの変更

composer config -g repos.packagist composer https://packagist.jp
  • packagist.org のデータを2分ごとに同期 1
  • さくら VPS + CloudFlare

高速化 Composer プラグイン

composer global require hirak/prestissimo
  • Keep-Alive の有効化
  • リダイレクト削減
  • 並列ダウンロード
bezeklik
サーバー管理、CMS構築のお仕事募集中。 CentOS / Apache / Nginx / PHP / MySQL / Docker / CMS (eZ Platform, eZ Publish, WordPress, Drupal) / Redmine
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away