Why switching Laragon PHP version?
It is very common to change PHP version when developing PHP applications, as different projects will depend on different PHP versions to satisfy the compatibility of their dependencies. Some cases requiring the PHP version to be switched include:
- The PHP platform you are working on requires a newer or old PHP version to run;
- The current PHP version is outdated and contains security vulnerabilities;
- You want to test new features on a different PHP version;
For PHP development on Windows with Laragon, knowing how to switch Laragon PHP version will be definitely helpful for your development. Fortunately, it is very easy to change Laragon PHP version, and this tutorial will guide you on how to do that.
Tutorial StartsChanging Laragon PHP version: Step by step
Below are step-by-step instructions on how to switch the current Laragon PHP version to another one.
*We assume that you already have Laragon running and working properly.
1. Download your preferred PHP version
Go to the official PHP.net Windows download page:
https://windows.php.net/download/
Here on this page, choose the PHP version number + thread support type you want to download.
- For PHP version number, this page lists only the latest, stable PHP versions (at the time of this article, 7.4.30, 8.0.23 and 8.1.10). If you want to download older version (eg. PHP 5), head to the archive page containing all PHP versions:
https://windows.php.net/downloads/releases/archives/
You will see a lot of PHP versions and download types, either.msi
as installation package or.zip
for zipped package. For Laragon, it is recommended to download the.zip
package. - For PHP thread support type, the recommended thread support type for Laragon is Non-thread-safe version, which has the name containing
nts
.
Example 1: with the latest PHP 8.1.10 version, simply click here to download the zip package:
Example 2: with the old PHP 5.6.40 version, pick this zip package on the Archive page:
2. Extract downloaded PHP version to Laragon PHP folder
Simply extract the download PHP version zipped package, and copy the whole folder to Laragon’s PHP folder – [Laragon installation path]\bin\php
:
3. Switch PHP version in Laragon
Laragon has a very nice feature to quickly switch the PHP version just by using its system tray menu.
Right click on Laragon system tray icon, choose PHP > Version [current PHP version] > [The new PHP version you wanted to use]
For example, we are choosing the downloaded PHP 8.1.10 version:
Right after switching PHP version, a Laragon notification will appear to indicate that the PHP version has been switched:
4. Reload Laragon
Open Laragon Control Panel, click Reload to reload Laragon’s Apache with the new PHP version:
5. Verify that new PHP version works in Laragon
You can verify the new PHP version by creating a PHP file (assuming phpinfo.php
) with the content:
<?php
phpinfo();
Open the file on your browser and recheck, the new PHP version is now loaded:
The tutorial is now over. It’s a very nice feature of Laragon to be able to quickly switch the PHP version, compared to XAMPP which we have to make several file adjustments as our Change XAMPP PHP version on Windows tutorial.
The only downside of this feature is you cannot run multiple different PHP versions at the same time on Laragon, but of course, there are other ways for that, which we will have another tutorial on a later time.