PHP

scoop is necessary
You can manage multiple versions of PHP on same machine with scoop, if you don't install it, check this guide: scoop

Install multiple PHP versions

If you try to install directly PHP with scoop you will have the last version, if you want to manage multiple versions, you need to install php bucket

PowerShell
scoop bucket add php

Try to search php with scoop

PowerShell
scoop search php

And you will find a lot of PHP versions, you can install any specific PHP version now. But you will nts versions and standard versions, if you want to use NGINX, I advice you to install nts version for each PHP version.

Install current version.

PowerShell
scoop install php-nts

Install specific version.

PowerShell
scoop install php8.1-nts

Switch PHP version

By default, the last PHP installed is the current version, here I install PHP 8.1 at the last, so current version with php -v will be 8.1. If I want to use PHP 8.2, I have just to use this command:

PowerShell
scoop reset php/php-nts

And php -v give me 8.2, I can back to PHP 8.1 when I want with scoop reset php/php8.1-nts.

php.ini

You will need to activate some extensions in php.ini, you will find it for each PHP version in each directory of PHP version installed: C:/Users/USERNAME/scoop/apps/php*-nts/current/php.ini. I offer an example of php.ini but you will need to update each php.ini.

php.ini config tips.

Composer

You can install composer if you want to use PHP packages:

PowerShell
scoop install composer

You can switch between composer version with

composer self-update --1 # composer v1
composer self-update --2 # composer v2

Setup Services for PHP

If you want to create VHost with NGINX and specific PHP version for each VHost, you will need to create Services. To do this, you will need NSSM (Non-Stucking Service Manager):

PowerShell
sudo scoop install nssm

Create service

And install a new service, here for PHP 8.2

PowerShell
sudo nssm install php8.2

You will have a window to create new service, two input will be important: Path and Parameter

For Path, get path of current php-nts, in this example, change USERNAME and php-nts if you set a different PHP version in Path

path
C:\Users\USERNAME\scoop\apps\php-nts\current\php-cgi.exe

For Parameter, you will need to create specific port with path of current php-nts, in this example change USERNAME, 9082 if you want a different port and php-nts if you set a different PHP version in Path

parameter
-b 127.0.0.1:9082 -c C:\Users\USERNAME\scoop\apps\php-nts\current\php.ini

Save the new service.

You can install another for PHP 8.1, for example:
path
C:\Users\USERNAME\scoop\apps\php8.1-nts\current\php-cgi.exe
For the port, I choose 9081 (for PHP 8.1)
parameter
-b 127.0.0.1:9081 -c C:\Users\USERNAME\scoop\apps\php8.1-nts\current\php.ini

Launch service

PowerShell
sudo nssm start php8.2

If you change some data, like with php.ini, you will need to restart Service

PowerShell
sudo nssm restart php8.2

Errors

cURL error 60: SSL certificate problem: unable to get local issuer certificate

If you have this error, you have a problem of certificate. You can manullay download certificate but I advice to use scoop.

sudo scoop install cacert

Open C:/Users/USERNAME/scoop/apps/php*-nts/current/php.ini to update this line, at ~1900 line

C:/Users/USERNAME/scoop/apps/php*-nts/current/php.ini
curl.cainfo = "C:\Users\USERNAME\scoop\apps\cacert\current\cacert.pem"

And restart PHP-FPM with NSSM

sudo nssm restart php[INSERT-HERE-VERSION]
You have to do this FOR EACH PHP version you use with you VHost. If you use php artisan serve with PHP 8.2 CLI, you have a VHost with PHP 8.1 and another VHost with PHP 8.0... You have to update all php.ini files which used by VHost or live serve with Laravel or Symfony.And you have to RESTART EACH version after php.ini file update.

PHP ini location problem

If Windows don't find php.ini assure yourself that this variable is set into Windows environnement variables for current user

PHP_INI_SCAN_DIR => [
    C:\Users\ewila\scoop\persist\php-nts
    C:\Users\ewila\scoop\apps\php-nts\current\conf.d
]

Note: theses variables change when you change your current PHP CLI version with scoop reset php/php-nts for example