Creating applications on the latest PHP versions may be necessary for a backend programmer’s work. Unfortunately, creators of MAMP rarely update their software for systems from Microsoft, so using new editions requires a little creativity from us.
Adding a new version of PHP to MAMP
Unlike previous MAMP releases, there is no need to mess around with Apache configuration files to add / remove new PHP versions.
All you have to do is add in the directory::
new folder, keeping the phpX.X.X format, where X.X.X is a unique version of the edition we are adding. May be in single digit format like 8.0.8, but 7.6.21 will also be conceit correctly.
Adding a period, comma or suffix like -alpha will prevent the folder from being interpreted correctly.
The latest stable version is available for download at:
PHP For Windows: Binaries and sources Releases – https://windows.php.net/
After downloading, put the contents of the archive into the newly created directory. For a standard folder on the C: / drive, the path should look something like this:
Version selection in MAMP
To change the version for individual projects, in the MAMP application, expand the Languages tab, and then PHP.
Choose the default version according to your preferences, it can even be the newest one. The option we are looking for is CGI Mode. Select it and restart the application completely.
After restarting, PHP versions should appear in the drop-down list next to the domain names.
If you are using Composer, its configuration depends on the php.ini file, which may change as a result of modifications made by MAMP. A safe option is to store a second copy of your PHP files in a different directory, to which tools such as Composer or Visual Studio Code will point to.
Testing the PHP 8.1 version
You can download new, yet unpublished versions of PHP from:
windows.php.net – /downloads/qa/ – https://windows.php.net/
In the file list you will find both the basic version:
as well as the Non-Thread-Safe:
Installation process is the same as for PHP 8.0. Create a new folder named
php8.1.0 in the \MAMP\bin\php directory.
After restarting, the new version should appear in the drop-down list.
Okay, does it even work?
To make sure that the files have been read correctly by MAMP, after restart, select one of the domains for which you have defined a newer PHP edition. Then in the General tab, click the information icon that appears next to the name of the selected PHP version.
Clicking the button will create a temporary file containing call to the phpinfo() function.
New versions of PHP introduces a number of performance improvements, but also extend the language with new syntax elements such as Enum. Even though almost half of the WordPress-based websites are still using version 7.4, we will definitely see a gradual change to new editions. It is worth to have open mind to new tools, requirements and possibilities.
2 responses to “PHP 8.1 & 8.0 in MAMP Pro for Windows”
Where can I download php 8.1 for MAMP on a Mac?