Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't run laravel 5.7 on php8

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

like image 801
arjilm Avatar asked Oct 27 '25 10:10

arjilm


1 Answers

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.

like image 50
Joshua Avatar answered Oct 30 '25 01:10

Joshua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!