Skip to content
KaarrotGet notified
← Blog

How to switch PHP versions on Windows

By ·

Client work rarely lines up on one PHP version. An older Laravel app might need PHP 8.1 while a new project wants 8.4. On Windows there is no built-in version manager, so here are two ways to handle it.

The manual way

1. Download the builds

Official Windows builds are on windows.php.net. Each version comes in two flavours:

  • Non Thread Safe (NTS): use this with Nginx or any server that runs PHP over FastCGI.
  • Thread Safe (TS): needed only when PHP runs as an Apache module.

Unzip each version into its own folder, for example C:\php\8.1 and C:\php\8.4.

2. Create a php.ini for each version

Every folder ships with php.ini-development. Copy it to php.ini and enable the extensions you need, such as pdo_mysql, mbstring, openssl and curl. Each version keeps its own file, so changes to one don’t affect another.

3. Point PATH at the version you want

The php command runs whichever folder appears first in your PATH. To switch, edit System Properties → Environment Variables → Path, move the folder you want to the top, and open a new terminal:

php -v

The catch

PATH is global. Switching it for one project switches it for all of them, and your web server needs its own config change too. Doing this several times a day gets tiring fast.

The faster way: per-project versions

A local environment manager can keep several versions installed and pick the right one per project. With Kaarrot it looks like this:

kaarrot php use 8.4            # global default
kaarrot php use 8.1 --project  # only this project

The project’s .test site and any terminal opened in its folder use the pinned version, while everything else keeps the global one. Composer follows the active version automatically.

Quick checklist

  • Use NTS builds with Nginx and FastCGI.
  • Keep one folder and one php.ini per version.
  • Run php -v and php --ini after switching to confirm which binary and config are active.

Kaarrot is a free, open-source PHP environment for Windows.

PHP versions, Nginx, databases, mail and HTTPS .test domains in one install.

Get notified at launch