hi guys I need help for this case
I can’t run laravel 5.7 on php8, when I do "php artisan serve"
I got error:
thrown in /var/www/html/myProject/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 838
PHP Fatal error: Uncaught ErrorException: Method ReflectionParameter::getClass() is deprecated in /var/www/html/myProject/vendor/laravel/framework/src/Illuminate/Container/Container.php:838
I have tried to update composer required php version form "^7.1.3"
to "php": "^7.1.3|^8.0",
and when I run composer update
I got another error.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework[v5.7.0, ..., 5.7.x-dev] require php ^7.1.3 -> your php version (8.0.3) does not satisfy that requirement.
- Root composer.json requires laravel/framework 5.7.* -> satisfiable by laravel/framework[v5.7.0, ..., 5.7.x-dev].
I hope any body sharing what is solution for this case
4
Answers
Laravel 5.7 is not compatible with PHP 8. If you want to get PHP 8 support, make sure you’re at the latest version of Laravel 6, 7, or 8.
There are also a couple of commonly used dependencies you’ll need to update in your
composer.json
file:php:^8.0
fakerphp/faker:^1.9.1
phpunit/phpunit:^9.3
Both errors are related.
According to The Official Docs Laravel 5.7 only supports PHP >= 7.1.3.
Trying to force it to run on PHP8 will cause some funky things as PHP8 has a lot of game changing fixes/migrations/deprecation. All of which can be found here.
If you want to use PHP8, use Laravel 8. If you want to use Laravel 5.7, use PHP7.
If you must use PHP8 and Laravel 5.7, I suggest you change the composer requiremnet to
"php": "^8.0",
but be prepared to troubleshoot a lot.You can putting
exit($e);
inAppExceptionsHandler::report()
to give a better error message.delete vendors file
then run the command composer install