composer install で「Your requirements could not be resolved to an installable set of packages.」のエラーになる件
本記事の環境は以下
- Windows10 Home
- WSL2 Ubuntu18.04
php artisan serve
を実行すると
PHP Warning: require(/var/www/html/pf-blog/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/html/pf-blog/artisan on line 18 PHP Fatal error: require(): Failed opening required '/var/www/html/pf-blog/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/html/pf-blog/artisan on line 18
っていうエラーを吐いてしまう
調べてみると
composer install
で解決するらしいのだがそもそもこれがうまくいかない
最初は気づかなかったのだがログをよく見てみると
Your requirements could not be resolved to an installable set of packages.
というエラーで止まってしまっているらしい
ログを見てみるとどうやらmbstringとdomが入っていないようだ
sudo apt install php7.2-mbstring php7.2-dom
そして今度は以下のようなエラーが
Failed to download league/flysystem 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
どうやらzipとunzipコマンドが入っていないらしい
sudo apt install -y zip unzip
もう一度
composer intall
すると
Package manifest generated successfully. 46 packages you are using are looking for funding. Use the `composer fund` command to find out more!
どうやら解決したようだ
php artisan serve
してhttp://127.0.0.1:8000にアクセスしてみると
無事テストページが表示された