Anaya Rojo
ES
← Blog

How do you work with multiple PHP versions on Windows?

March 27, 2020

multiphpversionswindows
How do you work with multiple PHP versions on Windows?

A bit of backstory:

First, a bit of context on the problem. As a PHP developer I work with Laravel, an elegant way to build with this language, starting with version 5.4 (I’m relatively new to the PHP world).

But new versions with better features keep coming out, making it more and more appealing to use version 6.0 or later. The problem started when I decided to develop this blog using the latest version of Laravel: I set up my development environment with PHP 7.2.7 and built out each feature over the course of two weeks. A few days later I wanted to pick back up projects on older PHP versions and ran into a real headache. I could only have one PHP version installed at a time ☹

Summary:

A couple of months later I stumbled onto the solution, and here it is:

  1. Install UwAmp, an alternative to XAMPP that works very similarly, except you can select between several PHP versions. https://www.uwamp.com/en/
  2. Specify the PHP version your project uses with Composer, using the following command:
composer config platform.php 7.2.7

Reference posts with the details and explanations:

https://www.desarrollolibre.net/blog/apache/como-tener-multiples-versiones-dos-o-mas-de-php-en-windows#.Xn1fP4hKiUl

https://andy-carter.com/blog/composer-php-platform

Leave your comment