Yesterday, the next major version of PHP got released. The new Version 7 was developed for almost two years and brings some awesome no functionalities. According to Wikipedia, over 80% of all Websites are using PHP. So if you have a Website, Blog or Forum, you will most likely come around PHP 7 in the next few months.
All details about the new version can be found on the PHP Website: PHP 7.0.0 Released
As great, as a new version of a product is, there is always the progress included to upgrade or migrate to this new version. Based on how deep the changes of the new version are, this process can sometimes be very intense and come along with upgrading your software to new versions, which are supporting in this case PHP 7.0
To give you a big picture, on how your current website is compatible with PHP 7.0 I wrote a PowerShell Scripts, that performs a Syntax Check on all PHP Files. The result gives you an idea if you can move without hesitation to the new version of PHP or if you need to change your current code.
The PowerShell Script is available on TechNet Gallery for download: PHP 7 Syntax Check using PowerShell
Along with the PowerShell Script, you’ll need to grab the following components:
Install Visual C++ 2015 Runtime
For PHP 7 to run, you need to have the 2015 Version of the Visual C++ Runtime installed. You should install the version (x86 or x64) that will match the version of PHP that you will download in the next step. If you are unsure, you can also install both versions.
Get PHP 7
Go to windows.php.net and download the PHP 7 Non Thread Safe Version. You can choose if you want to download the x86 or the x64 version. You should download the version that you plan to run on your Web-Server. Extract the downloaded content into a temporary place:
Run the Script
Execute the following Command in an elevated PowerShell Prompt, in the Directory where you downloaded Script. Adjust the Parameter Values if needed!
.\New-PHPSyntaxCheck.ps1 -Directory "C:\inetpub\wwwroot\msitproblog.com" -PhpExe "C:\Temp\PHP_7.0.0_NTS_X64\php.exe" -LogFile "C:\Temp\PHPSyntaxCheck.log"
This process can take a while, based on the size of your Website.
If there are any Syntax Errors, you will get a text that will tell you about the errors and the corresponding files:
The detailed log file, that was specified in the LogFile Parameter, shows the detailed results of each file:
One thing that you need to be aware of, is that this check is for Syntax Errors Only. The Script won’t find any logical errors!