php 8.1 as CLI
Posted by: webmasterinnj (---.cmdnnj.fios.verizon.net)
Date: December 11, 2022 07:34AM

hi!
so i have been using php 8.0 as a default for awhile now,i have installed the latest php 8.1 64 bit onto my wampserver and switched it to php 8.1
however CLI is still using php 8.0 and update 3.3.0 removed the ability to change that,how can i switch cli to 8.1 so i can delete php 8.0?

Options: ReplyQuote
Re: php 8.1 as CLI
Posted by: Otomatic (Moderator)
Date: December 11, 2022 10:41AM

Hi,

I remind that what is called "PHP CLI version" in Wampserver is the PHP version declared in the line
phpCliVersion =
of the file wampmanager.conf

AND THAT THIS VERSION IS ONLY USED FOR THE PHP SCRIPTS OF WAMPSERVER

When you want to use PHP in CLI mode, you can use any PHP version.

The reason I removed the ability to change the "CLI version" is because it is not useful to you and currently the internal PHP scripts of Wampserver are validated with PHP 7.4.33 and changing the version can expose you to problems. PHP 7.4.33 is the internal version of Wampserver 3.3.0 full install and I strongly advise you to install PHP 7.4.33 if it is not currently installed and to set this version as phpCliVersion.

In the near future, the [phpCli] section of wampmanager.conf will be removed and the PHP version number used for internal scripts will be stashed somewhere else.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: php 8.1 as CLI
Posted by: RiggsFolly (Moderator)
Date: December 11, 2022 07:04PM

Can I point you at this answer in StackOverflow

How To Run PHP From Windows Command Line in WAMPServer

as a suggestion on how to use the CLI in WAMPServer.

It allows much more flexability, shoudl you be responsible for one or multiple sites all of which need to run on different versions of PHP.
It also allows you to incorporate PEAR and Composer as well as just selecting the correct version of PHP CLI at any point in time

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: php 8.1 as CLI
Posted by: Otomatic (Moderator)
Date: December 12, 2022 03:48PM

Hi,

Wampmanager scripts use PHP in CLI mode in exactly the same way as you would do it manually from the command line.

For example for "Show PHP loaded Extensions" the corresponding line in wampmanager.ini that will be executed by Aestan Tray Menu is:
Type: item; Caption: "Show PHP loaded Extensions"; Action: run; FileName: "E:/wamp64/bin/php/php7.4.33/php.exe"; Parameters: "msg.php phploadedextensions";WorkingDir: "E:/wamp64/scripts"; Flags: waituntilterminated; Glyph: 24
Corresponds well to a command line (CLI) launching php.exe with parameters which, in this case are a php script name itself with a parameter.

- php.exe to launch:
E:/wamp64/bin/php/php7.4.33/php.exe
- First parameter script to launch
msg.php
- Second parameter -> parameter for the script above
phploadedextensions
There is no third parameter, which means that it will be for the PHP version used as an Apache module.
To do it for a PHP version used in FCGI mode, you need to add a third parameter, for example:
FCGI7.4.33

This would give for a command line:
E:/wamp64/bin/php/php7.4.33/php.exe msg.php phploadedextensions

But, there is one more parameter given for Aestan Tray Menu, it is
WorkingDir: "E:/wamp64/scripts"
which means that the command line must be executed while being positioned in the folder E:/wamp64/scripts

So, we open a command windows as an administrator then type :
CD /D E:\wamp64\scripts
E:/wamp64/bin/php/php7.4.33/php.exe msg.php phploadedextensions
And it gives the same result as launched via the Wampmanager menu.

I can change PHP version to change CLI, of course if this version exists in Wampserver, for example
E:/wamp64/bin/php/php8.0.26/php.exe msg.php phploadedextensions FCGI7.4.33
This shows that the use of PHP in CLI mode is independent of Wampserver, of course provided that the version of PHP exists.

Icing on the cake, it works even with Wampserver stopped.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote


Sorry, only registered users may post in this forum.