PHP
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
scoop bucket add php
Try to search php
with scoop
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.
scoop install php-nts
Install specific version.
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:
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.
- Example for PHP 7.1
- Example for PHP 7.3
- Example for PHP 7.4
- Example for PHP 8.0
- Example for PHP 8.1
- Example for PHP 8.2
php.ini
config tips.
Composer
You can install composer
if you want to use PHP packages:
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):
sudo scoop install nssm
Create service
And install a new service, here for PHP 8.2
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
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
-b 127.0.0.1:9082 -c C:\Users\USERNAME\scoop\apps\php-nts\current\php.ini
Save the new service.
C:\Users\USERNAME\scoop\apps\php8.1-nts\current\php-cgi.exe
9081
(for PHP 8.1)-b 127.0.0.1:9081 -c C:\Users\USERNAME\scoop\apps\php8.1-nts\current\php.ini
Launch service
sudo nssm start php8.2
If you change some data, like with php.ini, you will need to restart Service
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
curl.cainfo = "C:\Users\USERNAME\scoop\apps\cacert\current\cacert.pem"
And restart PHP-FPM with NSSM
sudo nssm restart php[INSERT-HERE-VERSION]
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