Many web developers, especially beginners, have a common question “How to update PHP version in XAMPP?”. After getting a lot of queries on the topic, we decided to write a short and simple tutorial on how you can easily update PHP version on your localhost.
Table Of Content:
XAMPP plays a significant role for web developers and it’s one of the most popular stacks that developers use to build and test websites locally. What makes it popular among developers is that even if something goes wrong with the code, it doesn’t affect the live web platform.
Working on the localhost is indeed a good practice to boost your web development skills and it is also common among WordPress developers. However, most users are left asking “How to update PHP version in XAMPP?” Or “How to upgrade PHP version in XAMPP?”.
Also, here on WPblog:
- How to Install XAMPP and Install WordPress on Localhost (XAMPP).
- If your website is ready, then migrate your site from localhost to live server.
In this tutorial, I will show you how easily you can update your PHP version in XAMPP through 4 simple steps. However, before embarking on the process you need to know why it is important to update your PHP version in XAMPP and when is the right time to change the PHP version.
Reasons to Update PHP Version in XAMPP
The PHP version requirements often varies with specifications of the project you are working on. Sometimes it’s the users who demand a newer PHP version which can compel you to update it. In most cases, whenever a new PHP version is rolled out, users and developers waste no time in updating their current versions to avoid security threats.
As a member of various developers’ community, I often see many developers still using the older version of XAMPP(i.e. XAMPP 3.2.1 or older) that runs on PHP 5. What they are mostly concerned with is updating the PHP version in their current XAMPP without reinstalling it all together.
PHP 7 offers an advanced set of functionalities as compared to PHP 5, which are all reasons why you should update your PHP version as soon as it is launched. Let’s look at why PHP 7 has the upper hand over PHP 5.
- For starters, PHP 7 is faster than any other version available, including PHP 5. Suppose, you have written a PHP code in PHP 5, if you run the same code on PHP 7, you will see a significant upgrade in performance.
- PHP 7 provides ease in error handling as compared to other older versions of PHP. If you are using PHP 5 then you would know how hard it is to handle fatal errors.
- PHP 7 supports anonymous class, a feature that is not available in any of the older PHP versions. Anonymous class is used to speed up the execution time which is common in other OOP languages like JAVA, C#, etc.
- PHP 7 supports 64 bit (large) files which you can run on 64 bit OS architecture. This feature is also not available on PHP 5.
- PHP 7 also includes null coalescing operators, accurate type declarations and many advanced features.
Now that we have understood how important it is to update your PHP version in XAMPP, let’s move forward and see how you can update your PHP version in 4 simple steps.
How to Update PHP Version in XAMPP in 4 Simple Steps
The beauty of the XAMPP lies in the fact that it’s a development server, not a production server. This means that you can play with its configuration and make simple changes like changing its PHP version without affecting your live application.
Note: I would recommend that before you upgrade PHP version in XAMPP, make a backup for your site files or project files. ALWAYS MAKE A BACKUP FOR DATA.
Updating PHP version in XAMPP is simple. All you need to do is follow these 4 simple steps.
Step 1: Download the latest version of PHP (i.e. PHP 7.x)
First, you need to click here to download the latest binary version of PHP. Make sure you download the Thread Safe Zip file depending upon your Windows version( x86 for 32-bit and x64 for 64-bit ), as you can see in the image below.
In the above image, you can see that I have downloaded the VC14x64 Thread Safe because my windows version is 64-bit.
Step 2: Extract the Zip File and Create PHP Folder
Next, create a new folder in your Windows desktop and name it PHP. Then, extract the Zip file into that new folder(i.e. PHP) .
Step 3: Rename the Old PHP Folder
Next, go to XAMPP folder and select the php folder and rename it with something like php_5 and then paste the extracted-new-php folder on XAMPP directory. You can see in the below image, how I did this.
Step 4: Configuring Apache Server
Next in the process is to configure the Apache server and for this, you need to open your XAMPP control panel then click on Apache Config > Apache (httpd-xampp.conf).
Then, an httpd-xampp.config file will open on your screen. Next, in the PHP-Module setup, paste the new lines of code and remove the previous lines of code like as shown in the below image.
Previous lines of code:
LoadFile “D:/xampp/php/php5ts.dll” LoadFile "D:/xampp/php/libpq.dll" LoadModule php5_module “D:/xampp/php/php5apache2_4.dll”
New lines of code:
LoadFile "D:/xampp/php/php7ts.dll" LoadFile "D:/xampp/php/libpq.dll" LoadModule php7_module "D:/xampp/php/php7apache2_4.dll"
Then, save the file and restart the XAMPP server. Tada! It’s done.
I hope this tutorial helped you to learn “How to update PHP version in XAMPP”. If you need any support or if you face any problem while upgrading the PHP version in XAMPP don’t hesitate to ping me in the comments section or email me at email@example.com, I would love to help you out!