Command Line Exectution
Posted by: jeberlan (104.129.204.---)
Date: January 09, 2017 08:40PM

I'm attempting to run a fully-functional php script from the command line and I'm getting different phpinfo() results.

I have a long running page that reads an Oracle database so I'd like to run it in a scheduled batch file. When I execute the script via the command line it tells me "Call to undefined function oci_connect". Tells me the same thing when I attempt other db types; "call to undefined function odbc_connect". Both of these work properly when executed in a browser.
If I run phpinfo() via the command line I get different results that when executed via a browser.

1 - Windows version used - Windows Server 2012 R2 (64)
2 - Version WampServer - wampServer Version 3.0.4 64 bit
3 - Apache Version - 2.4.18
4 - PHP Version - php 7.0.4 AND PHP 5.6.19 for CLI (Command-Line Interface) (obviously part of the problem since I've got a check mark next to the 7.0.4 version)
5 - MySQL Version - 5.7.11
6 - What color is the WampServer icon - green

Do I have to install all my extensions into the 5.6 version as well or can I change CLI to use 7.0?

Options: ReplyQuote
Re: Command Line Exectution
Posted by: Otomatic (Moderator)
Date: January 09, 2017 09:47PM

Hi,

Detailled answer tomorrow.
The PC is in backup. I am on Smartphone and it is not very easy to write long explanations.

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

Options: ReplyQuote
Re: Command Line Exectution
Posted by: RiggsFolly (Moderator)
Date: January 10, 2017 12:07AM

In WAMPServer there are 2 php.ini files

One, in \wamp\bin\php\php{version}\php.ini controls the CLI environment and the other \wamp\bin\apache\apache{version}\bin\php.ini controls the web environment


You need to make the changes that you made to activate the Oracle database extensions in the web php.ini file in the \wamp\bin\php\php{version}\php.ini so that the CLI has access to the OCI extension

---------------------------------------------------------------------------------------------
(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: Command Line Exectution
Posted by: Otomatic (Moderator)
Date: January 10, 2017 09:52AM

Hi,

> Version WampServer - wampServer Version 3.0.4 64 bit
You should apply the update 3.0.8.

RiggsFolly summarized the situation.

PHP version 5.6.19, noted as CLI, is used as a command line for all Wampserver internal scripts, for example to change a PHP option itself.
This is done by the lines of the wampmanager.ini file that is recreated each time Wampserver starts and each option change, for example:
wamp/bin/php/php5.6.25/php-win.exe switchPhpParam.php short_open_tag on
The PHP initialization file used for the command line is "wamp/bin/php/php5.6.25/php.ini", of course, if we use php 5.6.25.
If you use another version of PHP command line, this will be the php.ini file of the version used.

On the other hand, the PHP configuration file used in the "web" configuration is that of the apache version used, for example:
wamp\bin\apache\apache2.4.25\bin\php.ini
which is a symbolic link on the phpForApache.ini file of the PHP version used in "web" mode.

This "php.ini" duplicate method is used so that PHP modifications for the "web" are not likely to interfere with the PHP in CLI. This also avoids having to add paths to the Windows PATH.

I recommend that you use for your CLI applications a different PHP version than that reserved for the Wampserver CLI mode so as to avoid Wampserver crash if you make a mistake in the configuration of the php.ini file of your version.

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

Options: ReplyQuote


Sorry, only registered users may post in this forum.