PVM- The unpopular PHP Version Manager.

Kamasu Paul
2 min readOct 22, 2022

--

Photo by Ben Griffiths on Unsplash

If you have had a chance to work with different javascript projects that require different versions of nodejs, you have probably heard of nvm.

NVM is a nodejs version manager that helps you switch between different versions of nodejs when working with various projects having different nodejs version requirements. With nvm you can install, list and use different versions of nodejs on either windows or Linux without uninstalling one version to use another.

How About PHP? is there an nvm equivalent for PHP? are there PHP Version managers?

Yes, a number of PHP version managers exist for both Linux-based systems and windows. This StackOverflow post lists several alternatives including

  1. phpbrew
  2. phpenv
  3. php-version

But none of those quite work like nvm and are mostly suited for Linux-based operating systems. How about windows?

Meet PVM! — the unpopular php nvm equivalent

Pvm is a PHP version manager that works just like nvm but with only one disadvantage. You cant use pvm to install other php versions, rather you have to install them independently and then use the tool only to switch between already installed versions.

How do I install PVM?

Pvm requires you to have Composer already installed. (Another disadvantage). Then you can go ahead and install pvm using composer.

#install pvm using composer
composer global require hjbdev/pvm

Note: You have to add the pvm to your system PATH and it should be above any other php versions specified in the path.

PVM usage

  1. Discovery. The first step is php version discovery. After installation, you have to point the package to the directory having installations of different php versions. This is done using the pvm discover command. It requires specifying the path to the directory
#make the package discover your php versions. Specify your path
pvm discover path
#Example: pvm discover C:\wamp64\bin\php

2. Switching php versions. To switch between the different installed versions of php. First list the versions using pvm list, then select a version using pvm use <version>

#List available php versions
pvm list
#Select a php version
pvm use version
#Example: pvm use 8.1.11

To get more help about pvm use the pvm — help, this will list all the available options. Hopefully, pvm reduces your nightmares of switching between php versions.

That one minute. Happy coding!

--

--

Kamasu Paul

Software Engineer | Backend | APIs - On a journey to write 1000 articles in 1000 days