PHP 8.1 Support in Laravel Sail

October 15th, 2021

PHP 8.1 Support in Laravel Sail

Laravel added PHP 8.1 support to Laravel Sail earlier this week. While PHP 8.1 is not ready for production yet, you can start developing applications, testing packages, and getting ready for the PHP 8.1 GA release in November.

A special thanks to Dries Vints who contributed this update:

Updating Your Sail Project to PHP 8.1

If you want to start using PHP 8.1 in your Sail applications now, you can update the project's docker-compose.yml file build.context and image values to 8.1:

context: ./vendor/laravel/sail/runtimes/8.1
dockerfile: Dockerfile
image: sail-8.1/app
# ...

If you have an existing application with Sail, you'll need to run composer update to get the latest version of Sail that includes the 8.1 runtime:

composer update laravel/sail

After you're done updating the files, you can rerun Sail to get the latest changes:

./vendor/bin/sail down
./vendor/bin/sail build
./vendor/bin/sail up

With that, you should see something similar to the following on the welcome screen if you're starting a new Laravel application:

Laravel Running v8.64 with PHP 8.1 RC4

Learn More

If you'd like to learn more about the PHP 8.1 sail implementation, check out Pull Request #254 in the laravel/sail repo. I'd also recommend checking out the Installation and Sail documentation for setup and usage details.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.