Changing the php version in Laravel Sail

[00:00] Laravel Sail works with php 8.0 or php 7.4. If I type in sail php -v and hit enter, we'll see that by default, Sail applications are set up to use php 8. But what if, for some reason, we need to use php 7?

[00:21] Before you change anything, make sure to stop sail using sail down, then open the docker-compose.yml file and make the following changes: here, under laravel.test, build, context, make sure you change to runtimes/7.4 and then do the same for the image. Instead of sail-8.0, do sail-7.4 and save.

[00:55] Once you've done that, go inside the terminal and run the following command: sail build --no-cache. This will rebuild your container images.

[01:11] Finally run the sail up command to start sail again. And now if we type sail php -v again, we'll see that our new php version is 7.4.

Create an account to view the code snippets of this lesson.