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.
- Look through your backup or old computer for the site with the old version of PHP
- Go to the
/conf/php/
folder and find the version you need. - Copy the folder (php-5.6.39 in my case)
- Paste this folder into the
/conf/php
folder on your new site.
Find, Copy, and Paste the Local.app PHP folder version
- 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/
- Copy the folder
- Paste the folder (mine was named
php-5.6.39+6
) into your new machine’slightning-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.
- Navigate to `/userdir/Library/Application Support/
- Create a backup of
sites.json
and save it elsewhere - Open the sites.json in Application support in VS Code (I used VS Code’s format document to make the JSON easier to read)
- Search for the site you want to update
- Under the PHP object, replace the version value with the value you need (5.6.39 in my case)
- 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.