I was trying to create a new Laravel project when this error appeared in my terminal. The PHP process inside the container keeps restarting because of this error.
How to reproduce?
$ curl -s "https://laravel.build/example-app?with=mysql,redis,mailhog" | bash ... $ cd example-app example-app$ ./vendor/bin/sail up example-app.test-1 | usermod: no changes example-app.test-1 | 2021-10-29 13:37:29,645 INFO Set uid to user 0 succeeded example-app.test-1 | 2021-10-29 13:37:29,646 INFO supervisord started with pid 9 example-app.test-1 | 2021-10-29 13:37:30,649 INFO spawned: 'php' with pid 11 example-app.test-1 | Composer detected issues in your platform: example-app.test-1 | example-app.test-1 | Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.20.2021-10-29 13:37:31,672 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) example-app.test-1 | 2021-10-29 13:37:31,672 INFO exited: php (exit status 104; not expected) example-app.test-1 | 2021-10-29 13:37:32,675 INFO spawned: 'php' with pid 12 example-app.test-1 | Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.20.2021-10-29 13:37:33,695 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) example-app.test-1 | 2021-10-29 13:37:33,696 INFO exited: php (exit status 104; not expected) example-app.test-1 | 2021-10-29 13:37:34,699 INFO spawned: 'php' with pid 13 example-app.test-1 | Composer detected issues in your platform: example-app.test-1 | example-app.test-1 | Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.20.2021-10-29 13:37:35,720 INFO success: php entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) example-app.test-1 | 2021-10-29 13:37:35,721 INFO exited: php (exit status 104; not expected) example-app.test-1 | 2021-10-29 13:37:36,723 INFO spawned: 'php' with pid 14 ... and many more
Solution
Open composer.json using your favorite text editor and apply the following changes:
"php": "^7.3|^8.0",
Make sure Sail is still running despite the error.
example-app$ ./vendor/bin/sail bash (container)$ composer update (container)$ php artisan # this should work now
p/s: when I tried to reproduce this bug again (by reverting the changes above), the error did not appear anymore, but I’m still gonna publish this article because I think it might help somebody in the future ¯\_(ツ)_/¯
“magic” >.<
Memang padu la cai.. Looking forward for more meaningful content like this..