In this topic I'll explain how to get PHP 8 working within Wampserver and be able to switch between it and other versions of PHP.
EDIT: Fixed instructions for Wampserver 3.2.2.
EDIT2: Added missing extensions reported by Wampserver to phpForApache.ini.
Disclaimer: Wampserver does not officially support PHP 8 yet, so do this at your own risk. This guide is written for PHP 8.0.0 alpha 1. Things may change for newer preview releases, though I'm not expecting it to between now and the stable release. This is also for advanced users. If you don't know what you are doing, you may hose your Wampserver installation. If you have any doubts, I'd advise you to wait until PHP 8 stable when there should be an official Wampserver installer for it.
Pre-requisites: You need the latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019, which you can find on this page. Install the one applicable to your Wampserver installation.
Next you need to download the PHP 8.0.0 alpha 1 zip. You can find Windows binaries for preview PHP versions on this page. I normally recommend getting the thread safe version, but again pick the one that's applicable.
Once downloaded, navigate to your Wampserver folder and then go to bin\php, then create a new folder within called php8.0.0alpha1. For default 64-bit Wampserver installations this will be located at C:\wamp64\bin\php. Open the zip archive you've just downloaded and extract the contents to this new folder.
Normally if you're manually installing a new version of PHP this way, you can copy wampserver.conf and create a new phpForApache.ini file, then refresh Wampserver and call it a day. However, PHP 8 will not work out of the box by doing this and there a few extra steps that need to be done first.
Instead, you should create a new wampserver.conf file inside the php8.0.0alpha1 folder and paste the contents from below:
Next you should copy php.ini-development and rename the copy to phpForApache.ini. This is so that you have a fresh config file as a template. It will need changing in a few places in order to point to the correct folders. Look for the following lines and make these changes so that PHP 8 understands the Wampserver folder hierarchy. I'm using the paths for the default 64-bit Wampserver installation, so change these to wherever you have it installed.
Go to the root folder where Wampserver is installed (C:\wamp64 for default 64-bit installations). I recommend backing up the scripts folder within here in case you need to revert as a couple of scripts inside need to be changed. Bear in mind that you're going to be hacking these script files, so if you mess up it could cause Wampserver to stop functioning properly. Be sure you know how to recover in the event of this breaking something before you proceed. Also note that Wampserver updates may overwrite the scripts you will be modifying.
Navigate to the scripts folder.
Editing wampserver.lib.php was required for Wampserver 3.2.0, but is no longer needed if you update it to 3.2.2.
The main file that needs to be changed is wampserver.lib.php. You need to look for the following line (line 272 for me, but it may be different for you).
Change this to the following:
Now you'll be able to switch between PHP 8 and other versions within Wampserver without it getting stuck.
For good measure, there's one more script left to edit. Open config.inc.php and look for these lines:
One note is that JIT compilation is turned on by default within the php.ini file so you should see a decent performance improvement over PHP 7.4.
This guide should work for newer preview releases of PHP 8. They just need the paths changing to reflect that version.
Happy testing! :)
EDIT: Fixed instructions for Wampserver 3.2.2.
EDIT2: Added missing extensions reported by Wampserver to phpForApache.ini.
Disclaimer: Wampserver does not officially support PHP 8 yet, so do this at your own risk. This guide is written for PHP 8.0.0 alpha 1. Things may change for newer preview releases, though I'm not expecting it to between now and the stable release. This is also for advanced users. If you don't know what you are doing, you may hose your Wampserver installation. If you have any doubts, I'd advise you to wait until PHP 8 stable when there should be an official Wampserver installer for it.
Pre-requisites: You need the latest Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019, which you can find on this page. Install the one applicable to your Wampserver installation.
Next you need to download the PHP 8.0.0 alpha 1 zip. You can find Windows binaries for preview PHP versions on this page. I normally recommend getting the thread safe version, but again pick the one that's applicable.
Once downloaded, navigate to your Wampserver folder and then go to bin\php, then create a new folder within called php8.0.0alpha1. For default 64-bit Wampserver installations this will be located at C:\wamp64\bin\php. Open the zip archive you've just downloaded and extract the contents to this new folder.
Normally if you're manually installing a new version of PHP this way, you can copy wampserver.conf and create a new phpForApache.ini file, then refresh Wampserver and call it a day. However, PHP 8 will not work out of the box by doing this and there a few extra steps that need to be done first.
Instead, you should create a new wampserver.conf file inside the php8.0.0alpha1 folder and paste the contents from below:
<?php $phpConf['phpIniDir'] = '.'; $phpConf['phpExeDir'] = '.'; $phpConf['phpConfFile'] = 'php.ini'; //PHP 8 needs Apache 2.4.x and doesn't works with Apache 2.2.x //and php_module, not php7_module or php5_module $phpConf['apache']['2.4']['LoadModuleName'] = 'php_module'; $phpConf['apache']['2.4']['LoadModuleFile'] = 'php8apache2_4.dll'; $phpConf['apache']['2.4']['AddModule'] = ''; ?>The difference is that PHP 8 has renamed php7_module to php_module and php7apache2_4.dll is now php8apache2_4.dll.
Next you should copy php.ini-development and rename the copy to phpForApache.ini. This is so that you have a fresh config file as a template. It will need changing in a few places in order to point to the correct folders. Look for the following lines and make these changes so that PHP 8 understands the Wampserver folder hierarchy. I'm using the paths for the default 64-bit Wampserver installation, so change these to wherever you have it installed.
error_log ="c:/wamp64/logs/php_error.log"
extension_dir ="c:/wamp64/bin/php/php8.0.0alpha1/ext/"
upload_tmp_dir ="c:/wamp64/tmp"
sendmail_from ="admin@wampserver.invalid"
session.save_path ="c:/wamp64/tmp"
soap.wsdl_cache_dir="c:/wamp64/tmp"
[opcache] zend_extension="c:/wamp64/bin/php/php8.0.0alpha1/ext/php_opcache.dll"You probably want to enable the same extensions as you did with PHP 7.x as well. This is how I have it set up.
extension=bz2 extension=curl extension=com_dotnet ;extension=dba ;extension=enchant ;extension=ffi ;extension=ftp extension=fileinfo extension=gd2 extension=gettext extension=gmp extension=intl extension=imap extension=ldap extension=mbstring extension=exif ; Must be after mbstring as it depends on it extension=mysqli ;extension=oci8_12c ; Use with Oracle Database 12c Instant Client ;extension=odbc extension=openssl ;extension=pdo_firebird extension=pdo_mysql ;extension=pdo_oci ;extension=pdo_odbc ;extension=pdo_pgsql extension=pdo_sqlite ;extension=pgsql ;extension=phpdbg_webhelper ;extension=shmop ; The MIBS data available in the PHP distribution must be installed. ; See [www.php.net] ;extension=snmp extension=soap extension=sockets ;extension=sodium extension=sqlite3 ;extension=sysvshm ;extension=tidy extension=xsl ;extension=zend_test ;zend_extension=opcacheYou can configure the rest of the file as you see fit. I normally set these variables just for QoL.
max_execution_time = 120
post_max_size = 32M
upload_max_filesize = 32MWith that, PHP 8 is configured but it will still not work properly with Wampserver out of the box. Do not switch Wampserver to PHP 8 just yet, as you may not be able to switch back. To fix this, you will need to edit a couple of scripts in order to get them compatible.
Go to the root folder where Wampserver is installed (C:\wamp64 for default 64-bit installations). I recommend backing up the scripts folder within here in case you need to revert as a couple of scripts inside need to be changed. Bear in mind that you're going to be hacking these script files, so if you mess up it could cause Wampserver to stop functioning properly. Be sure you know how to recover in the event of this breaking something before you proceed. Also note that Wampserver updates may overwrite the scripts you will be modifying.
Navigate to the scripts folder.
Editing wampserver.lib.php was required for Wampserver 3.2.0, but is no longer needed if you update it to 3.2.2.
if (strpos($line,'LoadModule') !== false && (strpos($line,'php5_module') !== false || strpos($line,'php7_module') !== false))
if (strpos($line,'LoadModule') !== false && (strpos($line,'php5_module') !== false || strpos($line,'php7_module') !== false || strpos($line,'php_module') !== false))
For good measure, there's one more script left to edit. Open config.inc.php and look for these lines:
$phpDllToCopy = array_merge( $php_icu_dll, array ( 'libmysql.dll', 'libeay32.dll', 'ssleay32.dll', 'libsasl.dll', 'libpq.dll', 'libssh2.dll', //For php 5.5.17 'libsodium.dll', //For php 7.2.0 'libsqlite3.dll', //For php 7.4.0 'php5isapi.dll', 'php5nsapi.dll', 'php5ts.dll', 'php7ts.dll', //For PHP 7 ) );This needs php8ts.dll adding to the end of the array like this:
$phpDllToCopy = array_merge( $php_icu_dll, array ( 'libmysql.dll', 'libeay32.dll', 'ssleay32.dll', 'libsasl.dll', 'libpq.dll', 'libssh2.dll', //For php 5.5.17 'libsodium.dll', //For php 7.2.0 'libsqlite3.dll', //For php 7.4.0 'php5isapi.dll', 'php5nsapi.dll', 'php5ts.dll', 'php7ts.dll', //For PHP 7 'php8ts.dll', //For PHP 8 ) );Then finally at the end of the same file, there's another line that needs changing.
// Apache modules which should not be disabled $apacheModNotDisable = array( 'authz_core_module', 'authz_host_module', 'php5_module', 'php7_module', );This just needs php_module adding to the end of the array like this:
// Apache modules which should not be disabled $apacheModNotDisable = array( 'authz_core_module', 'authz_host_module', 'php5_module', 'php7_module', 'php_module', );And that should be it. Right click Wampserver in the system tray and select Refresh. It should pick up PHP 8. Then you should be able to switch to and from it just like any other version of PHP.
One note is that JIT compilation is turned on by default within the php.ini file so you should see a decent performance improvement over PHP 7.4.
This guide should work for newer preview releases of PHP 8. They just need the paths changing to reflect that version.
Happy testing! :)