DDEV Docker: How to change the project PHP version?

DDEV Docker Change PHP Version in Magento 2

Hello Magento Devs,

DDEV makes it easier to set up a Docker stack for your PHP developments and it provides great utility in Magento 2 development.

Today we are going to see,
How can we change the php version for any project inside the DDEV configuration? By default, DDEV uses 8.1 as per the current date.

We will see how to change and set our preferred php version for our Magento 2 project.

Step 1: Find the DDEV config file of the project

Go to the project root directory and navigate to the .ddev directory.

This is a hidden directory where project-related ddev configuration and other pieces of stuff are stored.

Inside this folder, you will be able to find some .yaml files and other container-related stuff.

Step 2: Update the PHP version in the config.yaml

Open the config.yaml file in your preferred text editor.

You will find the “php_version” variable changes its value to your preferred PHP version.

Step 3: Restart the project using the DDEV

After changing the PHP version, you will need to restart the web container to make changes affect.

You can do this quickly and easily using restarting DDEV with the below command.

Step 4: Check the current PHP version

After restarting the ddev containers you can now see the latest PHP version in your project configuration.

You can check this using the below command.

That’s it, I hope you find this blog useful.

Let me know if you have any queries in the comment box, see you soon in the next blog.

Keep Coding !!!

Leave a Reply

Your email address will not be published. Required fields are marked *