How to run PHP 5.6 on Local v8 and above

I came across a handful of posts and a feature request where people needed to run older versions of PHP, so I wrote this up to help people who needed the same. Yes, I know WordPress doesn’t support older versions below 7.4 anymore, but I have an old non-WordPress project I support that runs on PHP 5.6. The other use cases are I read from users seemed valid as well.

My situation was that I got a new laptop, and migrated most of my sites over, but one site I didn’t migrate and forgot about until I needed to test some local updates on and it only runs on PHP 5.6.

I thought there had to be a way to get an older version of PHP I had already been using on previous versions of Local running on newer versions of Local and I was able to hack together an easy solution.

If you migrated sites to a new computer, you’ll need to copy two folders. I’m on macOS, but it may work on Windows as well if you know where the folders are located.

Here’s what you’ll need

  • Copy of an old site with the folder of the version of PHP you need
  • Access to Local’s PHP version stored in /userdir/Library/Application Support/lightning-services/

Find, Copy, and Paste the sites’ PHP version you need from your Local site backup.

  1. Look through your backup or old computer for the site with the old version of PHP
  2. Go to the /conf/php/ folder and find the version you need.
  3. Copy the folder (php-5.6.39 in my case)
  4. Paste this folder into the /conf/php folder on your new site.

Find, Copy, and Paste the Local.app PHP folder version

  1. From your backup or old computer, navigate to the application support folder for local in your users directory. For macOS this was /userdir/Library/Application Support/lightning-services/
  2. Copy the folder
  3. Paste the folder (mine was named php-5.6.39+6) into your new machine’s lightning-services folder. I’m not sure what the +6 is.

Update the sites.json for Local.app

Now you need to tell Local.app that you want to use this decprepit (and deprecated) version of PHP.

local.app-sitesjson

  1. Navigate to `/userdir/Library/Application Support/
  2. Create a backup of sites.json and save it elsewhere
  3. Open the sites.json in Application support in VS Code (I used VS Code’s format document to make the JSON easier to read)
  4. Search for the site you want to update
  5. Under the PHP object, replace the version value with the value you need (5.6.39 in my case)
  6. Close the Local.app if you had it open, reopen it and now you should be able to set the PHP version to the this version.

I hope this helps people trying to run or test some old projects whether they’re using WP or not.

If you don’t have the folders from previous sites or installs, I’m curious if the Local team would provide those as a resource.

This may break some other Local feature, like the WP-CLI changes listed on v8.0.0, so proceed with caution by making a backup.

Thanks for documenting this!

2 Likes