PHP 8.1 Support in Laravel Sail
Published on by Paul Redmond
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:
As of with today's Laravel Sail release you can try out PHP 8.1! Update your runtime in your docker-compose.yml file to 8.1 and run "sail build --no-cache" to rebuild the container.
— Dries Vints (@driesvints) October 12, 2021
Please note that some PHP 8.1 extensions aren't yet available: https://t.co/oUAjErUL0q
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
:
services: laravel.test: build: context: ./vendor/laravel/sail/runtimes/8.1 dockerfile: Dockerfile args: WWWGROUP: '${WWWGROUP}' 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:
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.