PHP 5.6 and 7.x

chrislindsay used Ask the Experts™
Hi Experts,

Can I run PHP 5.6 and 7.x for the same website on IIS 8.  

I have a lot of legacy code which I want to keep but my all new development I want to utilize PHP 7.x

Is this possible in a production environment


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
as long as different page use different versions no problem. you'll need a bunch of rules or use explicit extensions such as "php7"

but then backwards compatibility is not that bad so porting your older work to php7 probably requires little work and possibly none.

but do not expect to include a 5.6 piece of code from 7.x or the reverse or expect sessions to work consistently on both versions unless you store them externally ( in memcache or sql for example )

personally, i would not recommend doing that in a single website/vhost
Systems Engineer
From the IIS scope, you can register multiple versions of PHP on a single server.  Then down at the site level, you can indicate what version the site should use.  To take it a step further, you can create a virtual directory or virtual application and change the setting there as well.

Though, as mentioned above, mixing PHP versions at the site level is something I would not recommend either.

I also recommend using PHP Manager for IIS on the server.  It makes managing PHP registrations and version settings easier to manage.


Running PHP in IIS:

Most Valuable Expert 2011
Top Expert 2016

in a production environment
Not to be flip, but if you have to ask the question, the answer is "no!"  Depending on your level of PHP and your diligence with security, modernity, etc., there may be breaking changes in PHP7, so you want to take some careful steps to accomplish the upgrade.

First, know why you want to upgrade.  Set measurable goals so you can see the advantages you want to get from the upgrade, and measure your progress against these goals.

Second, be certain that you have (as near as possible) complete code coverage in your tests, and a sturdy test data set that you can exercise quickly and easily.

Third, read the migration guides.  Then read them again.

I agree with skullnobrains on this (I usually do): You might want to consider using a different file suffix for the PHP7 code.  I recall using .php and .php5 when PHP5 was introduced.  It helped keep everything well-segregated, and allowed us to make piecemeal changes in the 400+ scripts that required upgrades.  I don't really know much about Windows, but in a Linux environment you can use .htaccess to control PHP versions and settings on a directory-by-directory basis -- very handy!


Thanks Guys.  It looks like updating from 5.6 to 7 is relatively straightforward  and maybe this is the best way to go....
Thanks for you help...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial