Laravel in PHP 8 dev

hazardco picture hazardco · Aug 16, 2020 · Viewed 12.4k times · Source

I have a docker container with php 8.0.0-dev and composer. I want to create a Laravel application to test the new PHP but I have some errors.

When I try to create a new laravel project with the command:

composer create-project laravel/laravel test

The error I get is that I don't have the required PHP even though php 8.0.0 is greater than php 7.x.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (8.0.0-dev) does not satisfy that requirement.
    - laravel/framework v5.6.8 requires php ^7.1.3 -> your PHP version (8.0.0-dev) does not satisfy that requirement.
    ...
    ...

Can I skip the php version check somehow?

I have tried with

--prefer-dist

and

--ignore-platform-reqs

but i obtain this error:

 Problem 1
    - Conclusion: don't install laravel/laravel v7.25.0|remove laravel/laravel v7.25.0
    - Installation request for laravel/laravel v7.25.0 -> satisfiable by laravel/laravel[v7.25.0].

Any idea?

Thanks!!!

Answer

Jsowa picture Jsowa · Nov 30, 2020

Laravel supports PHP 8.0 right now, however still some packages are not updated. It affects also some of the PHP extensions: https://blog.remirepo.net/pages/PECL-extensions-RPM-status

First, make sure you're at the latest version of Laravel 6, 7 or 8 to get PHP 8 support. Then make sure you're on the very latest version of any first-party package from Laravel like Passport, Cashier, Dusk, etc.

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

Finally, run composer update to update other packages. Make sure to test your application before updating production. That's it! Enjoy PHP 8!

Source: https://blog.laravel.com/laravel-php-8-support