Swap PHP Version.
SPV is a high-density, lightweight, zero-dependency, Perl based CLI utility for developers to manage multiple PHP environments on Windows by modifying the Registry directly. No complex environments, no symlink magic - just clean %PATH% management.
Built entirely in Perl as a standalone app.
|
|
4 months ago | |
|---|---|---|
| .gitignore | 4 months ago | |
| license | 4 months ago | |
| logo.png | 4 months ago | |
| readme.md | 4 months ago | |
| spv.pl | 4 months ago |
by Dwayne Pivac @ OMI Ltd.
SPV is a high-density, lightweight, zero-dependency, Perl based CLI utility for developers
to manage multiple PHP environments on Windows
by modifying the Registry directly.
No complex environments, no symlink magic - just clean %PATH% management.
Built entirely in Perl as a standalone app.
cfg for configuration) and common typos (e.g., versoin) so you don't have to be perfect to be fast. See Commands and Aliases for the full list.path you can view your PATH environment with each path on a new line.spv fave.perl spv.pl config run, you must provide the full physical path to your PHP root directory (e.g., c:\wamp64\bin\php or c:\php_installs).install command to unpack new PHP versions. Install it via: cpan Archive::Zip or cpanm Archive::ZipOpen a Command Prompt (Admin) and change to the directory you wish to install SPV.
Then clone the repo :
cd /usr/bin/spv
git clone https://vcs.nz/ominz/spv.git .
The app will download directly into the directory you are in.
The trailing dot in the clone command above means current directory.
Then unzip the files into the directory you will run SPV from.
Run the configuration command perl spv.pl config. The utility will walk you through several key preferences to tailor the environment to your machine:
c:\wamp64\bin\php).spv fave command.32 for x86 or 64 for x64).install command fetches the correct binaries.ts (Thread Safe) or nts (Non-Thread Safe).install process.6).https://windows.php.net/downloads/releases/archives/).spv path. Use registry to maintain the actual Windows inheritance order (System then User), or alpha for a de-duplicated, alphabetical list in lowercase.registry).
Thread Safety note :
NTS - Use this if you run PHP through IIS (FastCGI) or Nginx.
TS - Use this if you run PHP as an Apache Module.PHP PATH note :
If PHP is not in your path ...
When prompted for the PHP Root, paste the path to your PHP binaries directory.
After you've run the configuration, runperl spv.pl listto get a list of available PHP versions you can switch to.
Then runperl spv.pl use [version]to officially link your chosen PHP version to your Windows PATH.
Setup generates a wrapper spv.cmd and offers to add the directory to your Windows PATH automatically.
perl spv.pl setup
Note :
If you say 'no', you'll need to manually move the generatedspv.cmdto a directory already in your PATH.
You can use SPV to list all known PATHs :perl spv.pl path
Close and reopen your console (or run refresh if you use Cmder) to refresh the environment.
spv list
Shows all available PHP versions found in your configured PHP root.
The active version is marked with a *.
spv list
Updates your Windows Registry PATH to use the specified version.
SPV is smart: it finds where your current PHP sits and swaps it in-place, maintaining your PATH order.
spv use 8.1.20
or simply leave out use. SPV knows what you mean ;)
spv 8.1.20
Quickly switch to your pre-defined favourite PHP version (configured via config).
spv favourite
or even shorter is
spv fave
Scrapes the configured download URL to find available versions.
You choose a version from the interactive list provided.
spv install
Note :
This requires theArchive::ZipPerl module.
Displays a list of your current Windows PATH directories, with one entry per line.
spv path
Displays SPV version information and the version for the php.exe currently active in your PATH.
spv version
Scans your current PATH to find every instance of php.exe. Useful for finding conflicting installations.
spv where
Re-run the configuration utility to update your PHP root, architecture, or other preferences.
spv configuration
or type less with
spv config
Displays detailed information about the app logic, versioning, and the developer.
spv about
Displays a full summary of all available commands, including usage examples.
spv help
SETX (which truncates at 1024 chars). We write directly to HKLM (if Admin) or HKCU to ensure safety and support for long PATH strings.use command performs an "in-place swap."\) for maximum compatibility with the Windows Command Processor.use or setup, the tool automatically vacuums your PATH, removing empty entries and duplicates.spv config)All commands have aliases. Shortcut ways of getting the job done quicker.
It's also helpful if, lkie me, you can't sepll.
Note all configs are case insensitive.
| Full Command | Aliases |
|---|---|
| list | l ls lsit -l --l -list --list |
| use | u ues switch -u --u -use --use |
| version | v ver vers versoin -v --v -version --version |
| path | p pth paht -p --p -path --path |
| where | w whereis wheres where's whers locate find -w --w -where --where |
| install | i in inst instal intsal -i --i -install --install |
| about | a abuot abowt abut abot inf info information infomation -a --a -about --about |
| help | h ? hlp help! ! -? -h --h -help --help |
| configuration | c config conf cfg cf -c --c -config --config |
| favourite | f fave fav favorite -f --f -fave --fave |
| setup | s set-up stup cmd makecmd make-cmd bat batch makebat make-bat -s --s -setup --setup |
If you see the following error when trying to clone the repository:
fatal: unable to access '...': SSL certificate problem: unable to get local issuer certificate
This usually means Git cannot find its Certificate Authority bundle.
You can fix this by pointing Git to the correct .crt file (adjust the path to match your actual Cmder/Git location):
git config --global http.sslcainfo "c:\usr\cmder\vendor\git-for-windows\mingw64\ssl\certs\ca-bundle.crt"
If running the git config command above results in:
error: could not lock config file ...: No such file or directory
Your %HOME% environment variable is pointing to a directory that does not exist.
Ensure your %HOME% variable is set to a valid path (like your %USERPROFILE%) before running the command.
If a git clone fails with a fatal: message but no following text, check your hosts file.
If you are on a local network where the router intercepts HTTPS traffic,
(e.g., redirecting to a setup page), you must manually map the domain to the correct internal IP in:
c:\Windows\System32\drivers\etc\hosts
By default, Windows requires you to type perl spv.pl. To run SPV as a first-class command (e.g., just typing spv list), you need to configure two things: PATHEXT and File Association.
Windows uses the PATHEXT variable to determine which file types it can run without typing the extension. Adding .PL allows you to type spv instead of spv.pl.
Check your current list:
echo %PATHEXT%
Add .PL (User Level) if it's not in your PATHEXT:
setx PATHEXT "%PATHEXT%;.PL"
Even if .pl files are associated with Perl, Windows often fails to pass arguments (like version numbers) to the script. To fix this, the registry association must be updated to include %*.
The Logic:
"C:\path\to\perl.exe" "%1" %*%* - it ensures that when you type spv use 8.4.1, the 8.4.1 actually reaches the script.