Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (94.142.12.---)
Date: April 08, 2018 12:08AM

Good day.
I have just uninstalled Wampserver 3.1.0 and installed Wampserver 3.1.3.
New Wamp itself is so far so good. Icon is green, MariaDB has no conflicts with MySQL, 3 services are running OK.
However, I had to remove PHP and MySQL from system Path Variable as Wampserver 3.1.3 has required.
What shall I do know with my Composer?
Windows command prompt doesn't know it anymore.
I also cannot refer either to php or mysql in cmd anymore and do not think it's a good idea.
Looking forward to appropriate advices.
Best Regards,
Mike

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: April 08, 2018 09:30AM

Hi,

If you absolutely need the PHP and MySQL paths in the PATH environment variable, you can avoid the Wampserver alarm :
Right-Click wampmanager tray icon -> Wamp settings -> Do not verify PATH (to check it)

Using the PATH to launch applications is a survivorship of the past and it will cause you big problems if you change versions of PHP.

Note : This is only a warning from Wampserver that you can ignore.

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

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (94.142.12.---)
Date: April 08, 2018 10:17AM

Thank you.
However as soon as I put paths to php and mysql\bin folders to system Path environment variable - green light becomes orange and I see "2 of 3 services running".
Somehow MariaDB and MySQL are conflicting and MySQL won.
I reinstalled Wampserver 3.1.3 anew and this time MariaDB won.
Most probably, if I disable MariaDB, - this will help to turn orange into green. - But I still belive that there is a different solution to have all 3 services running, about which I don't know yet.
Please help.
I really like Wampserver.

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: April 08, 2018 11:55AM

Hi,

With my Wampserver 3.1.3 fresh install I put "j:\wamp\bin\mysql\mysql5.7.21\bin\" into PATH variable then restart Windows.
When I launch Wampserver Icon is green with error at the bottom sayning that there is j:\wamp\bin\mysql\mysql5.7.21\bin\ into PATH.

MySQL 5.7.21 use port 3306 and is default DBMS
MariasDB 10.2.14 use port 3307

See errors in Mariadb log.

When Mariadb is OK the last lines are:

2018-04-08 10:52:44 4068 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2018-04-08 10:52:44 4068 [Note] InnoDB: 5.7.21 started; log sequence number 1620520
2018-04-08 10:52:44 6644 [Note] InnoDB: Loading buffer pool(s) from j:\wamp\bin\mariadb\mariadb10.2.14\data\ib_buffer_pool
2018-04-08 10:52:44 4068 [Note] Plugin 'FEEDBACK' is disabled.
2018-04-08 10:52:44 6644 [Note] InnoDB: Buffer pool(s) load completed at 180408 11:52:44
2018-04-08 10:52:44 4068 [Note] Server socket created on IP: '::'.
2018-04-08 10:52:44 4068 [Note] Reading of all Master_info entries succeded
2018-04-08 10:52:44 4068 [Note] Added new Master_info '' to hash table
2018-04-08 10:52:44 4068 [Note] wampmariadb: ready for connections.
Version: '10.2.14-MariaDB' socket: '' port: 3307 mariadb.org binary distribution

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

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (94.142.12.---)
Date: April 08, 2018 01:01PM

Thank you.

One general result . IT ALL WORKS as you described the last time. And it's great!

Some peculiar details are as follows:

1) if I put "c:\wamp64\bin\mysql\mysql5.7.21\bin" into PATH variable and don't restart Win, - icon is orange

2) if I put "c:\wamp64\bin\mysql\mysql5.7.21\bin" into PATH variable and DO restart Win, - icon is green

3) if I put "c:\wamp64\bin\mysql\mysql5.7.21" into new MYSQL_HOME variable , then put "%MYSQL_HOME%\bin" into PATH variable and DO restart Win, - icon is orange

This is of course trivial, but nevermind. I can live with this smiling smiley

Thanks for help and great product,

Best regards,
Mike

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: April 08, 2018 02:38PM

Hi,

The first point to consider is that for changes to environment variables to be taken into account by Windows, it is essential to perform a restart.

The second point to take into account is the search order of the php.ini and my.ini files which, in principle, first looks in the folders pointed to by the PATH variable before looking in the own folder of the current PHP or MySQL or MariaDB version.

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

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (---.pppoe.avangarddsl.ru)
Date: April 08, 2018 06:27PM

Thanks for your precious replies.

After fresh install of Wampserver 3.1.3 - both PHP CLI and PHP web were 5.6.35

I made the following:

1) Left-Click - PHP - Version -> 7.2.4

2) put "C:\wamp64\bin\php\php7.2.4" into PATH variable

3) run in cmd "php --version" and get "PHP 7.2.4 (cli) ..."

Does it mean that I haven't got to do: Right-Click - Tools - Change PHP CLI version -> 7.2.4 ?

I am asking this since when I do Right-Click - Tools - I still see white text on grey background "PHP CLI = 5.6.35 - WEB = 7.2.4"

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: April 08, 2018 06:57PM

Hi,

> I still see white text on grey background "PHP CLI = 5.6.35 - WEB = 7.2.4"
CLI 5.6.35 is used by Wampmanager PHP internal scripts.
That is seen by informations in wampmanager.conf file :
phpVersion = "7.2.4"
phpCliVersion ="5.6.35"

Without any reference to a path on a PHP version in the PATH environment variable, in a Windows command window:
php --version returns:
'php' is not recognized as an internal command
or external, an executable program or a command file.

On your system, it works without error since you created a path on PHP 7.2.4 in the PATH variable, so the php-version command returns the information from version 7.2.4, since it is the only one known to PATH.
> PHP 7.2.4 (cli)
And (cli) simply indicates that PHP is running from the command line and not that it is the CLI version of Wampserver.

On the other hand, if you always run the same command from a Windows command window, but with a full path, you will get information about the PHP version pointed to by the full path.

C:\Windows\system32>j:\wamp\bin\php\php7.1.16\php.exe --version
PHP 7.1.16 (cli) (built: Mar 28 2018 21:27:36) ( ZTS MSVC14 (Visual C++ 2015) x86 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

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

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (---.pppoe.avangarddsl.ru)
Date: April 08, 2018 09:21PM

Thank you.

Now this is all sorted out for me.

In fact I need PHP in system PATH variable so that to use Composer in cmd.

And I need MySQL in system PATH variable so that to make convenient mass mysqldump while moving DBs during upgrade of Wampserver.

Best Regards,
Mike

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: RiggsFolly (Moderator)
Date: April 09, 2018 11:05AM

Mike,

No you dont, to both of those reasons.

All you need is a couple of simple .bat file placed in a folder that is ALREADY on your PATH

I call this one `phppath.cmd`
It looks after PATHing any of my PHP versions and COMPOSER and PEAR also if you want it BUT for only the duration of the life of a Command Window

@echo off

REM **********************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:\Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM *                   if no Parameter is put on the bat file
REM * - composerInstalled : Where I insatlled composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM *               possible version of PHP I have installed
REM **********************************************************************


set baseWamp=D:\wamp
set defaultPHPver=7.0.23
set composerInstalled=%baseWamp%\composer
set phpFolder=\bin\php\php

if %1.==. (
    set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
    set phpver=%baseWamp%%phpFolder%%1
)

PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------


REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP

IF exist %phpver%\pear (
    set PHP_PEAR_SYSCONF_DIR=D:\wamp\bin\php\php%phpver%
    set PHP_PEAR_INSTALL_DIR=D:\wamp\bin\php\php%phpver%\pear
    set PHP_PEAR_DOC_DIR=D:\wamp\bin\php\php%phpver%\docs
    set PHP_PEAR_BIN_DIR=D:\wamp\bin\php\php%phpver%
    set PHP_PEAR_DATA_DIR=D:\wamp\bin\php\php%phpver%\data
    set PHP_PEAR_PHP_BIN=D:\wamp\bin\php\php%phpver%\php.exe
    set PHP_PEAR_TEST_DIR=D:\wamp\bin\php\php%phpver%\tests

    echo PEAR INCLUDED IN THIS CONFIG
    echo ---------------------------------------------------------------
) else (
    echo PEAR DOES NOT EXIST IN THIS VERSION OF php
    echo ---------------------------------------------------------------
)

REM IF COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
    ECHO COMPOSER INCLUDED IN THIS CONFIG
    echo ---------------------------------------------------------------
    set COMPOSER_HOME=%baseWamp%\composer
    set COMPOSER_CACHE_DIR=%baseWamp%\composer

    PATH=%PATH%;%baseWamp%\composer

    rem echo TO UPDATE COMPOSER do > composer self-update
    echo ---------------------------------------------------------------
) else (
    echo ---------------------------------------------------------------
    echo COMPOSER IS NOT INSTALLED
    echo ---------------------------------------------------------------
)

set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=


I call this one `mysqlpath.cmd`
@echo off

set baseWamp=D:\wamp
set MySQLFolder=\bin\mysql\mysql
set defaultMySQLver=5.7.19

if %1.==. (
    set mysqlver=%baseWamp%%MySQLFolder%%defaultMySQLver%\bin
) else (
    set mysqlver=%baseWamp%%MySQLFolder%%1\bin
)


PATH=%PATH%;%mysqlver%
echo
echo -----------------------------------------------
mysql -V
echo -----------------------------------------------
echo

set baseWamp=
set MySQLFolder=
set defaultMySQLver=


You set them up to have the most likely default version set, then you can run them from any CMD prompt as

Uses default version
phppath 
mysqlpath

Uses a specific version
phppath 7.2.1
mysqlpath 5.7.22


And there you are.

There is absolutely NO NEED to add anything into the Windows PATH because that will ALWAYS just cause you issues later when you change versions of either PHP or MySQL

---------------------------------------------------------------------------------------------
(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-



Edited 2 time(s). Last edit at 04/09/2018 11:07AM by RiggsFolly.

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: baursak (---.pppoe.avangarddsl.ru)
Date: April 10, 2018 06:40AM

Thank you.

I have found already the post here
[forum.wampserver.com]

And done .cmd file for PHP.

After that I blended .cmd for MySQL. - But yours is of course authentic and I will use it.

Now neither PHP nor MySQL are there in my system PATH anymore.

Best Regards,
Mike

BTW, you have set of very useful instructions here

[wampserver.aviatechno.net]

These two .cmd files would absolutely relevant there to avoid questions like mine.

And also thank you for your check_vcredist utility. You are the only ones who respect MS Visual C++ already installed on client side and offer to install only those, which are absent.

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: bayeg (---.11-180-91.adsl-dyn.isp.belgacom.be)
Date: June 21, 2018 11:43AM

Hi,

Where did you add these files ?

Thanks

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: RiggsFolly (Moderator)
Date: June 21, 2018 12:44PM

Hi bayeg

Where did he install which files?

---------------------------------------------------------------------------------------------
(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: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: quantumweb (---.15-1.cable.virginm.net)
Date: August 18, 2018 08:44PM

This doesn't work in Powershell. Does anybody know how to make it work under powerhell? Thanks

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: August 19, 2018 09:15AM

Hi,

Powershell supports cmd.exe

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

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: unfun (---.184.189.46.rev.vodafone.pt)
Date: March 18, 2022 11:41PM

Hello all!

Another way is to add to path, yes, but change the contents of that same folder to the desired php.

Sounds crazy, wait for it.

In my case, and I think of most who code in PHP, the terminals we SSH to are usually linux bash, so I prefer to do my development with Git Bash for windows to emulate linux terminal, so the following code applies to windows users with Git Bash mainly, but same principle can be used in command prompt.

To briefly explain my code, I create a symbolic link to the desired PHP version in "c:\scripts" called "www" so then I can safely add "C:\Scripts\www" to my path variable.

For this user only has to set up their own settings, like WAMP folder and default PHP version, when user wants to change version in CLI, will read PHP sub-folders to see what versions you have installed, stick those in a numeric array and then loop through this array and show user installed versions, when user selects one, it will delete the "www" current symbolic link in c:\scripts and create a new one pointing to chosen PHP desired version's exe.

It works a treat to me, then I just added an alias to MySQL so I can create my project and my DB straight at once.

Here's how i done it:

For git bash, jsut create a file called .bashrc in your user's folder with the following and then adjust to your own needs. Fairly Readable code, I like to think, hope it is useful for others. smiling smiley

Here it goes:


#!/bin/bash

default_php=php8.1.0;
default_mysql=mysql5.7.36;

php_folder=/c/wamp64/bin/php/;
mysql_folder=/c/wamp64/bin/mysql/;

current_folder=$PWD;

main_link_folder=/c/Scripts;
link_php=www;

# In this case I would add C:\Scripts\www to my PATH variable

echo '____________________________________';

echo "PHP CLI Version: ${default_php//[!.0-9]/}, to change press P";
echo "MySQL CLI Version: ${default_mysql//[!.0-9]/}, to change press M";
echo '____________________________________';

while : ; do
    read -s -n 1 k <&1
    if [[ $k = p ]] ; then

        for entry in "$php_folder"/*
        do 
            if [[ ! $entry == *.txt ]]; then
                arrVar[${#arrVar[@]}]=$(basename $entry)
            fi
        done
        for i in "${!arrVar[@]}"
            do   
            echo "$i : PHP  ${arrVar[$i]//[!.0-9]/}"
        done
        read -s -n 1 opt <&1
        if [ "${arrVar[opt]+abc}" ]; then
                cd $main_link_folder
                    rm -rf $link_php
                    ln -rsfT $php_folder${arrVar[$opt]} $link_php
                cd $current_folder
                    alias mysql="winpty $mysql_folder$default_mysql/bin/mysql.exe"
                return
        else
            cd $main_link_folder
                rm -rf $link_php
                ln -rsfT $php_folder$default_php $link_php
            cd $current_folder
                alias mysql="winpty $mysql_folder$default_mysql/bin/mysql.exe"
            return
        fi
    else
        cd $main_link_folder
            rm -rf $link_php
            ln -rsfT $php_folder$default_php $link_php
        cd $current_folder
            alias mysql="winpty $mysql_folder$default_mysql/bin/mysql.exe"
        return
    fi
done
break



Edited 2 time(s). Last edit at 03/19/2022 03:25AM by unfun.

Options: ReplyQuote
Re: Wampserver 3.1.3: how to explain to composer lack of PHP Path Variable
Posted by: Otomatic (Moderator)
Date: March 19, 2022 10:44AM

Hi,

And Baursak patiently waited four years for an answer!

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

Options: ReplyQuote


Sorry, only registered users may post in this forum.