読者です 読者をやめる 読者になる 読者になる

楽しいだけで十分です

好きなことを書きます

PHPUnitを、Composerでインストールする時のメモ

PHPUnitをComposerでインストールする時に少しハマったのでメモ。
実行環境は次のものです。

やったこと

  • composer.jsonに記述した後に、composer installを実行すると、「PHP extension domがないよ」と言われました。
$ php composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/phpunit 5.5.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 5.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - Installation request for phpunit/phpunit 5.5.* -> satisfiable by phpunit/phpunit[5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7].
  • ということで、PHP extension domを追加してあげます。
$ sudo yum -y install php-xml
  • 再び、composer installを実行すると、今度は「zipを解凍するコマンドがないよ」と言われました。
$ php composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 26 installs, 0 updates, 0 removals
    Failed to download sebastian/resource-operations from dist: The zip extension and unzip command are both missing,skipping.
  • ということで、unzipを追加してあげます。
$ sudo yum -y install unzip
  • composer installを実行すると、今度こそPHPUnitのインストールに成功しました!
$ php composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 26 installs, 0 updates, 0 removals
  - Installing sebastian/resource-operations (1.0.0) Downloading: 100%
  - Installing sebastian/recursion-context (1.0.2) Downloading: 100%
  - Installing sebastian/object-enumerator (1.0.0) Downloading: 100%
~ 中略 ~
Writing lock file
Generating autoload files
  • 作業は以上です。月並みながら、エラーメッセージ読むの大事だなあと思いました。

参考

blue-goheimochi.hatenablog.com