LoginSignup
18
21

More than 5 years have passed since last update.

【PHP】PHP extension(PHP拡張モジュール)の確認と有効化(ext-fileinfo、ext-gd編)

Last updated at Posted at 2019-04-01

TL;DR

composer installでエラーが発生した際の解決までのメモ
(原因はPHP拡張モジュールの有効化がされてないことでした)

composer installでエラー

他のプロジェクトへ途中参加することになったのでいつも通りにクローンからのcomposer install
するとエラーが発生

>composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for league/flysystem 1.0.47 -> satisfiable by league/flysystem[1.0.47].
    - league/flysystem 1.0.47 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
  Problem 2
    - Installation request for phpoffice/phpspreadsheet 1.4.1 -> satisfiable by phpoffice/phpspreadsheet[1.4.1].
    - phpoffice/phpspreadsheet 1.4.1 requires ext-gd * -> the requested PHP extension gd is missing from your system.
  Problem 3
    - league/flysystem 1.0.47 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
    - laravel/framework v5.7.9 requires league/flysystem ^1.0.8 -> satisfiable by league/flysystem[1.0.47].
    - Installation request for laravel/framework v5.7.9 -> satisfiable by laravel/framework[v5.7.9].

  To enable extensions, verify that they are enabled in your .ini files:
    - C:\tools\php71\php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

エラー内容的にPHP拡張モジュールがないみたいなエラーが

PHP拡張の確認

>php -i | grep ext-fileinfo

確認したが入ってなかった。

PHP7.2系の最新をインストール

とりあえず使用していたPHPのバージョンが7.1系だったので7.2系の最新をChocolatey経由でインストール
(ここではPHPのバージョン違いをインストールするとエラーがでるので--forceオプションを指定してます)

>choco install php --version 7.2.15 --force

-f, --force
Force - force the behavior. Do not use force during normal operation -
it subverts some of the smart behavior for commands.

※強制実行コマンドなので実行時は慎重にしてください

インストールされたか確認

>choco list -lo

PHPのiniファイルを変更

以下を探して有効化(コメントを外す)

ext-fileinfoの有効化

php.ini
extension=php_fileinfo.dll

ext-gdの有効化

php.ini
extension=php_gd2.dll

一度ログアウト後再びcomposer install

> composer install

無事動きました

参考URL

18
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
21