ある日、PHPのLaravel入門の本(通称青本)をもとに環境構築しているときのことでした。
php artisan serve
を叩いたところ、こんなエラーメッセージが、、
※DeskTopにlaravelapp
という名前でプロジェクト作成しています。
PHP Warning: require(C:\Users\ユーザー名\Desktop\laravelapp/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\ユーザー名\Desktop\laravelapp\artisan on line 18
PHP Fatal error: Uncaught Error: Failed opening required 'C:\Users\ユーザー名\Desktop\laravelapp/vendor/autoload.php' (include_path='.;C:\php\pear') in C:\Users\ユーザー名\Desktop\laravelapp\artisan:18
Stack trace:
#0 {main}
thrown in C:\Users\ユーザー名\Desktop\laravelapp\artisan on line 18
調べたところ、 composer install
や、 composer update
を叩くとautoload.phpが落とせるらしい。。
composer install
をたたてみた。
ムムム。。。。
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.2.3) does not satisfy that requirement.
- league/mime-type-detection[1.4.0, ..., 1.11.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension.
- laravel/framework v10.0.0 requires league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.12.2].
- league/flysystem[3.8.0, ..., 3.12.2] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.11.0].
- Root composer.json requires laravel/framework ^10.0 -> satisfiable by laravel/framework[v10.0.0].
To enable extensions, verify that they are enabled in your .ini files:
- C:\Program Files\php-8.2\php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.
composer update
も同じメッセージだった。。 見てみると、
you can run Composer with `--ignore-platform-req=ext-fileinfo` to temporarily ignore these required extensions.
とかいてありますね。
composer update --ignore-platform-req=ext-fileinfo
これをたたいてみます。
おおお動いた
Loading composer repositories with package information
Updating dependencies
Lock file operations: 106 installs, 0 updates, 0 removals
- Locking brick/math (0.10.2)
- Locking dflydev/dot-access-data (v3.0.2)
- Locking doctrine/inflector (2.0.6)
- Locking doctrine/lexer (3.0.0)
- Locking dragonmantank/cron-expression (v3.3.2)
- Locking egulias/email-validator (4.0.1)
- Locking fakerphp/faker (v1.21.0)
- Locking filp/whoops (2.14.6)
- Locking fruitcake/php-cors (v1.2.0)
- Locking graham-campbell/result-type (v1.1.0)
- Locking guzzlehttp/guzzle (7.5.0)
- Locking guzzlehttp/promises (1.5.2)
- Locking guzzlehttp/psr7 (2.4.3)
====================以下略=================
結構長かったです。5分くらいかな。
php artisan serve
をしたら無事起動できました。