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::
[…]\MAMP\bin\php
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.
WATCH OUT!
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:
php-8.1.0alpha3-Win32-vs16-x64.zip,
as well as the Non-Thread-Safe:
php-8.1.0alpha3-nts-win32-vs16-x64.zip
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?
Hi Beat,
If you have already installed the newest MAMP (v6.6) you can enable the PHP 8+ in the PHP tab (left bar) and next to “Default version” you have to click on “plus” icon.
If you’re installing whole MAMP environment, the PHP 8+ should be installed by default.
Leave a Reply