skip to Main Content

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


  1. 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 to php:^8.0
    • Faker to fakerphp/faker:^1.9.1
    • PHPUnit to phpunit/phpunit:^9.3
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. You can putting exit($e); in AppExceptionsHandler::report() to give a better error message.

    Login or Signup to reply.
  4. delete vendors file
    then run the command composer install

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search