【PHP】PHP extension(PHP拡張モジュール)の確認と有効化(ext-fileinfo、ext-gd編)
4212 ワード
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
>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ファイルを変更
>choco list -lo
以下を探して有効化(コメントを外す)
ext-fileinfoの有効化
php.ini
extension=php_fileinfo.dll
ext-gdの有効化
php.ini
extension=php_gd2.dll
一度ログアウト後再びcomposer install
> composer install
> composer install
無事動きました
参考URL
Author And Source
この問題について(【PHP】PHP extension(PHP拡張モジュール)の確認と有効化(ext-fileinfo、ext-gd編)), 我々は、より多くの情報をここで見つけました https://qiita.com/sola-msr/items/95e06e66730468b6c7bc著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .