PHP version switching not working

The PHP version switching feature in DevKinsta is not working. Despite setting a site to use PHP 8.3 in the DevKinsta interface, the actual containers continue to run PHP 7.4.33, preventing the use of PHP 8+ syntax in WordPress development.

Environment Details

  • DevKinsta Version: 2.13.4
  • Operating System: macOS
  • Docker Version: 28.3.2, build 578ccf6
  • Site Name: ncwit
  • Expected PHP Version: 8.3
  • Actual PHP Version: 7.4.33

Current Docker Images

All DevKinsta images are version 1.3.6 and appear to be 16 months old:

kinsta/devkinsta_mailhog      1.3.6      f060baef253c   16 months ago   392MB
kinsta/devkinsta_adminer      1.3.6      0e94ac87d142   16 months ago   94.8MB
kinsta/devkinsta_nginx        1.3.6      b123f3cff7e8   16 months ago   53.3MB
kinsta/devkinsta_db           1.3.6      fb86d6cbbb8a   16 months ago   397MB
kinsta/devkinsta_fmp          1.3.6      edc7803a86f1   16 months ago   647MB

Steps Taken to Reproduce/Fix

  1. Changed PHP version in DevKinsta interface:

    • Opened site settings in DevKinsta
    • Changed PHP version from 7.4 to 8.3
    • DevKinsta interface shows PHP 8.3 is selected
  2. Verified the issue:

    • Site runs correctly in browser
    • Container still shows PHP 7.4.33: docker exec -u www-data -it devkinsta_fpm bash then php -v
    • PHP 8+ syntax (like match expressions) causes parse errors
  3. Attempted complete rebuild:

    • Stopped site in DevKinsta
    • Quit DevKinsta completely
    • Removed all containers: docker stop and docker rm for all devkinsta containers
    • Removed all images: docker rmi for all kinsta images
    • Restarted DevKinsta and recreated site
    • Result: DevKinsta downloaded the same 1.3.6 images with PHP 7.4.33
  4. Checked for updates:

    • No updates available for DevKinsta application

Expected Behavior

When I set a site to use PHP 8.3 in the DevKinsta interface, the actual PHP runtime in the containers should be PHP 8.3, allowing the use of PHP 8+ language features.

Actual Behavior

The DevKinsta interface shows PHP 8.3 is selected, but the containers continue to run PHP 7.4.33. This creates a development/production environment mismatch since our production servers run PHP 8+.

Impact

  • Cannot use PHP 8+ syntax features in local development
  • Development environment doesn’t match production environment (PHP 8+)
  • wp-cli fails due to PHP syntax errors when code uses PHP 8+ features
  • Blocks local WordPress development workflow

Questions

  1. Are the 1.3.6 Docker images the latest available? If not, how can I force DevKinsta to download newer images?
  2. Is there a manual way to update the Docker images that DevKinsta uses?
  3. Should PHP version switching work with the current version of DevKinsta? If so, what might be preventing it from working correctly?
  4. Are there any configuration files or settings I can check/modify to troubleshoot this issue?
  5. Is there a recommended alternative for local WordPress development with reliable PHP 8+ support?

Please let me know what additional information or diagnostic steps would be helpful to resolve this issue.

Continuing the discussion from PHP version switching not working:

Howdy @juliaset :waving_hand:,

Thank you kindly for sharing those details.

Please find answers to each of your questions below, as well as steps to switch the PHP version in command line.

  1. Are the 1.3.6 Docker images the latest available?
    Yes, these are the latest

  2. Is there a manual way to update the Docker images that DevKinsta uses?
    You can delete the images and relaunch DK. That should force it to update the images. But, 1.3.6 are the latest.

  3. Should PHP version switching work with the current version of DevKinsta? If so, what might be preventing it from working correctly?
    It is technically switching the PHP version as intended. However, the switcher just switches the PHP-FPM version. It doesn’t relink the PHP executable for commands run via the command line.

  4. Are there any configuration files or settings I can check/modify to troubleshoot this issue?
    Please follow the steps I’ll provide below.

  5. Is there a recommended alternative for local WordPress development with reliable PHP 8+ support?
    DevKinsta supports PHP 8+, and can be reliably used to develop a WordPress site. The alternative would be to set up a local LAMP/LEMP stack if they want.

I tried the following on my instance of DevKinsta, and it worked.

If you’d like to switch the PHP version used when executing PHP commands from the terminal, you can do the following:

docker exec -u root -it devkinsta_fpm bash

Then, run the following:
update-alternatives --config php

That should allow you to select which PHP version to use…

Alternatively, you can set the PHP version in a non-interactive way by specifying the PHP binary to use.

For example, to immediately set PHP 8.3 for use, you can run the following:
update-alternatives --set php /usr/bin/php8.3

1 Like

Thank you so much for the detailed response and clear explanation of how DevKinsta handles PHP versions.

Following your instructions, I was able to set the PHP CLI to 8.3 and am able to run wp-cli again. Issue resolved!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

@juliaset

No problem friend.

I’m glad that worked out.

Stay awesome :call_me_hand: