終電23時11分って早くね?

都内のIT企業で働くカラオケ大好きエンジニアの雑記

composerでPHPUnitがインストールできない

composerでPHPUnitをインストールしたかったんですが、
下記エラーが発生。

環境は

OS: CentOS6.4
PHP: 5.4.17

composer.jsonの内容はこんな感じでいたって普通。

{
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    },
    "config": {
        "bin-dir": "/usr/local/bin/"
    }
}


【エラー内容】

[root@luffy ~]# composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phpunit/phpunit 3.7.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.22 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.21 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.20 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.19 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.18 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.17 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.16 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.15 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.14 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.13 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.12 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.11 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.10 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 3.7.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - Installation request for phpunit/phpunit 3.7.* -> satisfiable by phpunit/phpunit[3.7.0, 3.7.1, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.7.14, 3.7.15, 3.7.16, 3.7.17, 3.7.18, 3.7.19, 3.7.2, 3.7.20, 3.7.21, 3.7.22, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9].

最初はPHPUnitのバージョンがPHPに対応してないとかそんな感じかなー
と思ったので、composer.jsonでPHPUnitのバージョン指定を変えてみてとか
いろいろ試したんですが解決せず。。

てか最初からエラー内容見てみろよって話なんです 笑

phpunit/phpunit 3.7.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.

phpunit/phpunit 3.7.9 には ext-dom が必要です。
・あんたのシステムにPHP extension domをリクエストしたけどなかったよ。

ってことなので、
DOM Extensionをインストール。

[root@luffy ~]# yum install php-xml

で、再度composerでPHPUnitをインストールすると・・・

[root@luffy ~]# composer install

Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing symfony/yaml (dev-master 4d80b4f)
    Downloading: 100%

  - Installing phpunit/php-text-template (dev-master 1eeef10)
    Downloading: 100%

  - Installing phpunit/phpunit-mock-objects (1.2.x-dev 3e40f3b)
    Downloading: 100%

  - Installing phpunit/php-timer (1.0.x-dev ecf7920)
    Downloading: 100%

  - Installing phpunit/php-token-stream (dev-master c25dd88)
    Downloading: 100%

  - Installing phpunit/php-file-iterator (dev-master 2deb24c)
    Downloading: 100%

  - Installing phpunit/php-code-coverage (1.2.x-dev d274ffb)
    Downloading: 100%

  - Installing phpunit/phpunit (3.7.x-dev 3.7.22)
    Downloading: 100%

  - Removing symfony/translation (2.3.x-dev v2.3.2)
  - Installing symfony/translation (2.3.x-dev 9451303)
    Downloading: 100%

  - Removing symfony/routing (2.3.x-dev v2.3.2)
  - Installing symfony/routing (2.3.x-dev 036c990)
    Downloading: 100%

  - Removing symfony/process (2.3.x-dev v2.3.2)
  - Installing symfony/process (2.3.x-dev 41801e8)
    Downloading: 100%

  - Removing symfony/http-foundation (2.3.x-dev v2.3.2)
  - Installing symfony/http-foundation (2.3.x-dev b4b8939)
    Downloading: 100%

  - Removing symfony/event-dispatcher (2.3.x-dev v2.3.2)
  - Installing symfony/event-dispatcher (2.3.x-dev 41c9826)
    Downloading: 100%

  - Removing symfony/http-kernel (2.3.x-dev 515d24c)
  - Installing symfony/http-kernel (2.3.x-dev 491ab88)
    Downloading: 100%

  - Removing symfony/finder (2.3.x-dev v2.3.2)
  - Installing symfony/finder (2.3.x-dev b251476)
    Downloading: 100%

  - Removing symfony/dom-crawler (2.3.x-dev v2.3.2)
  - Installing symfony/dom-crawler (2.3.x-dev e05e07f)
    Downloading: 100%

  - Removing symfony/css-selector (2.3.x-dev v2.3.2)
  - Installing symfony/css-selector (2.3.x-dev 8855442)
    Downloading: 100%

  - Removing symfony/console (2.3.x-dev v2.3.2)
  - Installing symfony/console (2.3.x-dev 290fe87)
    Downloading: 100%

  - Removing symfony/browser-kit (2.3.x-dev v2.3.2)
  - Installing symfony/browser-kit (2.3.x-dev 2639dc4)
    Downloading: 100%

  - Removing symfony/filesystem (dev-master 18460cf)
  - Installing symfony/filesystem (dev-master 59ee050)
    Downloading: 100%

phpunit/phpunit-mock-objects suggests installing ext-soap (*)
phpunit/php-code-coverage suggests installing ext-xdebug (>=2.0.5)
phpunit/phpunit suggests installing phpunit/php-invoker (>=1.1.0,<1.2.0)
Writing lock file
Generating autoload files
Generating optimized class loader
Compiling common classes

よし、成功!!

[root@luffy ~]# phpunit --version
PHPUnit 3.7.22 by Sebastian Bergmann.

無事、PHPUnitの3.7.22がインストールされましたとさ!