Adding New PHP Version to Ampps without a premium license

February 17, 2024 in General
Image

Before I go into this, consider supporting the Ampps project. Any time something else helps you and you download it, you should consider buying the developer a coffee.

Ampps is a LAMP development setup that allows you for you run a webserver. In my case, I am using Ampps to run a local environment for WordPress development on Windows. Recently, I ran into a problem with Composer requiring at least PHP 8 or greater. To my surprise, updating to another PHP version requires a license key to download the package.

So, I was off to the races to install a new PHP version and also keep the PHP packages separate so I could change the version back to PHP 7.4 (the default PHP version with Ampps). The idea was to add a new PHP version and have it work as if I had the premium license so I could still use Ampps to control which PHP version I was developing for.

Fortunately, the developers of Ampps are forward thinkers and use stock packages and tie them into Ampps using configuration files. After some trial an error, installing a new PHP version was straight forward!

Installing (Simple)

Download: https://www.justin-greer.com/wp-content/uploads/2024/02/Ampps-php81.zip

Download the files and add them to your Ampps root directory. In my case it was C:\Program Files\Ampps.

This will add a folder called “php81” to the root directory. It will also update the packages directory called “php81” and update the app data file to show the PHP version in the Ampps control panel.

Installing (Manual)

You will need to download your desired PHP version by at https://windows.php.net/download/. Be sure to download the proper PHP package. You will need to download the Safe Tread version of what ever version you want. Also note, you should download the ZIP download. This contains all the files you need for PHP and windows.

For this example, I will be installing PHP 8.1.27

Step 1 – Create

Create a directory called “php81” in the root directory of Ampps. In my case it is C:\Program Files\Ampps

Step 2 – Extracted PHP Files

Unzip the PHP package you downloaded from the PHP website and extract the contents of this file into the “php81” directory.

Step 3 – Create Package Directory

Create a folder called “php81” in the packages folder. It is easier to copy the php74 directory and rename it php81. Once you have the new folder created, you will need to modify the files here. Mainly, the “info.json” file.

{
    "mod":32,
    "version":"8.1.27",
    "space":"80011264",
    "release_date":"02-11-2023",
    "name":"PHP 8.1",
    "softname":"php81",
    "ins":"1",
    "type":"app",
    "group_type":"php",
    "category":"server_side_scripting",
    "os":"win",
    "arch":"64",
    "support":"https://php.net",
    "desc":"PHP is a popular general-purpose scripting language that is especially suited to web development.",
    "description":"PHP is a popular general-purpose scripting language that is especially suited to web development. Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world.",
    "conf_name":["PHP conf"],
    "conf":["php81/ampps/php-8.1.27.ini"],
    "logs":[],
    "logs_name":[],
    "extension_path":"/ext",
    "check_extension":"*extension*=*php_*.dll",
    "uncheck_extension":"*;*extension*=*php_*.dll",
    "conf_path":"/php81/ampps/php-8.1.27.ini",
    "dir":"/php81/ext",
    "bin":"php/php.exe",
    "restore":{"default":"/php81/ampps/php-8.1.27.ini","original":"/php81/ampps/original-php-8.1.27.ini"},
    "path_conf":"/php81/php.ini",
    "dir_path":"/php81",
    "dir_file":"php.ini",
    "soft_php":"0",
    "fullname":"PHP 8.1.27",
    "default":"0"
}

Step 4 – Update the Apps file

Go to Ampps\data\apps and edit the file to include the PHP81 app. This is JSON formatted but all you have to do is add the following to the end of the file. Be sure that the JSON is valid and there are no syntax errors.

"11": {
        "aid": "11",
        "default": "1",
        "fullname": "PHP 8.1",
        "group_type": "php",
        "name": "php81",
        "type": "app",
        "version": "8.1.27"
    }

Step 5 – Create the php.ini file

The last thing you need to do is create the php.ini file in the php81 directory in the root of Ampps. I recommend copying the contents of the php.ini file from php74 and pasted it into the new php.ini file in the php81 directory.

Once the contents is pasted, you just need to update the relative paths to use php81.

Conclusion

Once you have the new files in place, you will see a new option in the PHP selection for Ampps. You can now select the new PHP version just as if you have a premium key.

I have not tested this with any other version of PHP but I am pretty sure this will work with other PHP versions as well. You would just have to update the package and data file.

Enjoy

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments