PHPのフレームワークであるlaravelをcomposerからインストールしようとすると、以下のようにエラー"laravel/framework vX.X.X requires ext-mbstring"が出ることがあります。
$ /usr/local/bin/composer create-project --prefer-dist laravel/laravel blog
Installing laravel/laravel (v5.7.0)
Failed to download laravel/laravel from dist: The zip extension and unzip command are both missing, skipping.
Your command-line PHP is using multiple ini files. Run `php --ini` to show them.
Now trying to download from source
- Installing laravel/laravel (v5.7.0): Cloning b0651d2467
Created project in /home/app
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
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
- laravel/framework v5.7.9 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.8 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.7 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.6 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.5 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.4 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.3 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.7.2 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
...
原因
これは、インストールする環境に必要なPHPのextensionがインストールされていないためです。
解決方法
CentOSを使用しているときは、以下のようにyumコマンドなどで必要なextensionをインストールします
sudo yum install php-mbstring php-dom
こちらもおススメ