【PHP】Laravel phpunit requires ext-dom * -> the requested PHP extension dom is missing from your systemエラー

PHP xmlパッケージがインストールされていない時に、Laravelをインストールしようとすると表示されるエラーメッセージについてのメモ

動作環境

  • PHP 7.2.15-0ubuntu0.18.04.1
  • Laravel 5.8

エラーの内容

ComposerにLaravelのインストールする

composer create-project --prefer-dist laravel/laravel プロジェクトディレクトリ名

以下のメッセージが表示される

Problem 1
    - phpunit/phpunit 7.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - phpunit/phpunit 7.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    - Installation request for phpunit/phpunit ^7.5 -> satisfiable by phpunit/phpunit[7.5.0, 7.5.1, 7.5.2, 7.5.3, 7.5.4, 7.5.5, 7.5.6, 7.5.7, 7.5.8, 7.5.x-dev].

原因

PHPUnitに必要な「ext-dom」PHP extensionがインストールされていない

対応

「ext-dom」は「xml」パッケージに入っているのでインストールする

[root@hostname /]#
apt-get -y install php7.2-xml