Include path not changing when I updated php.ini - php

I've run the following to determine which php.ini file is being used - php -i | grep 'Configuration file'.
I've then updated that php.ini file with the following - include_path = ".:/usr/share/php:/usr/local/bin
Then I restarted apache. But when I run a php script with the content - <?php var_dump(include 'non/existant/file.php'); it tells me the following:
Warning: include(non/existant/file.php): failed to open stream: No such file or directory in /var/www/debug_phpunit.php on line 3 Warning: include(): Failed opening 'non/existant/file.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/debug_phpunit.php on line 3 bool(false)
Notice the include path in the error message. My changes aren't there. Am I changing the wrong file? Could another configuration file be overwriting this?

Related

MAMP (windows) different php.ini loaded from console..why?

I try to load PHP from console (in windows) and when I run phpinfo.php the line
Loaded Configuration File => (none)
but when I run this pagin in web browser I see it:
Loaded Configuration File C:\MAMP\conf\php5.6.28\php.ini
My problem appear when I try to install symfony
Warning: readfile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
Warning: readfile(https://symfony.com/installer): failed to open stream: Invalid argument in Command line code on line 1
I can't able to download this file from console, can anyone help me please?

Drupal cron error: failed to open stream

I've set up my Drupal 7 cron job like so:
/usr/local/bin/php /home/myaccount/public_html/cron.php
However, cron sends me an email with the following error message:
Warning: include_once(/home/myaccount/includes/bootstrap.inc): failed to open stream: No such file or directory in /home/myaccount/public_html/cron.php on line 13
Warning: include_once(): Failed opening '/home/myaccount/includes/bootstrap.inc' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/myaccount/public_html/cron.php on line 13
Fatal error: Call to undefined function drupal_bootstrap() in /home/tente myaccount studios/public_html/cron.php on line 14
It appears that cron is somehow stripping out public_html from the path. I uploaded a temporary PHP file and printed out getcwd() and it reports the path correctly, including public_html. So somewhere between line 11 when DRUPAL_ROOT is defined as getcwd() and line 13 when the include is called, something strips out public_html from the path.
You should use curl to call your webserver so that the correct php.ini and openbasedir directives are set. See https://www.drupal.org/cron

phalcon webtools.php: not in include_path

I created a project using phalcon command line
phalcon create-project brujobs --enable-webtools
When i test the webtools page i get
Warning: require(/home/myname/phalcon-devtools/scripts/Phalcon/Web/Tools.php): failed to open stream: Permission denied in /var/www/vhost/dev.myname.be/htdocs/myname/public/webtools.php on line 22 Fatal error: require(): Failed opening required '/home/myname/phalcon-devtools/scripts/Phalcon/Web/Tools.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/vhost/dev.myname.be/htdocs/myname/public/webtools.php on line 22
I suppose the issue is that phalcon is trying to include files that are not included in my php include_path directive.
include_path .:/usr/share/pear:/usr/share/php .:/usr/share/pear:/usr/share/php
Question is: what would be the proper way to fix that? Modify the whole server's php.ini file 's include_path directive just for phalcon webtools feels wrong to me.

Include_path in php.ini

I'm trying to send mail using PEAR framework (and WAMP).
I installed PEAR and package MAIL and it is in correct folder. Problem is with include_path in php.ini.
When I checked where is my php.ini (php --ini), I have result:
Configuration File (php.ini) Path: C:\Windows
Loaded Configuration File: C:\wamp\bin\php\php5.3.13\php.ini
Scan for additional .ini files in:
Additional .ini files parsed:
In C:\wamp\bin\php\php5.3.13\php.ini I set:
include_path = ".;C:\wamp\bin\php\php5.3.13\pear"
And I restarded WAMP.
After click button to send mail, I have following error:
Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\send_mail.php on line 2
Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\send_mail.php on line 2
Fatal error: Class 'Mail' not found in C:\wamp\www\send_mail.php on line 45
No idea, why include_path is here '.;C:\php\pear'.
Mike B told me to look at your phpinfo() to know exactly what ini file(s) are being used. The file was differ between cli and apache calls (php --ini is misleading).

PHPUnit fatal error and include_path

I just installed PHP and PEAR on my Mac OSX using MacPorts and then installed PHPUnit using PEAR. When I try to run PHPUnit, I get the following error message:
$ phpunit StackTest.php
PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Okay, so the file File/Iterator/Autoload.php isn't in my include_path, so I tried
$ ls -l /opt/local/lib/php/File/Iterator/Autoload.php
-rw-r--r-- 1 root admin 2682 May 23 14:38 /opt/local/lib/php/File/Iterator/Autoload.php
$ phpunit --include-path /opt/local/lib/php StackTest.php
PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.:/php/includes:/usr/local/php5/lib/php:/opt/local/lib/php/pear') in /opt/local/lib/php/PHPUnit/Autoload.php on line 45
It's still not working, and the it's not including the new path that it should be. Does anybody know what I can do about this? (I'd rather not modify my php.ini file if I can help it because it's read-only and I'm fairly new to PHP and don't want to mangle it in ways I don't understand.) Thanks.
Still don't have an answer for why --include-path on the command line isn't working, so here's what I did:
$ which phpunit
/opt/local/bin/phpunit
$ sudo emacs /opt/local/bin/phpunit
The plan is to modify the php.ini file, so first I had to figure out which php.ini was initializing phpunit. If anyone has a better way to do this, I'm happy to hear it. I added the following line to the phpunit code right after the <?php opening tag:
echo php_ini_loaded_file();
Now, when I ran phpunit, I got the following (here truncated) output:
/opt/local/etc/php5/php.iniPHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in /opt/local/lib/php/PHPUnit/Autoload.php on line 45...
Then:
$ sudo emacs /opt/local/etc/php5/php.ini
I searched for the include_path directive and appended :/opt/local/lib/php to the end. So now, phpunit works, although I have no idea if I broke anything else in terms of my setup.
I had a similar problem with a Windows install, but I am not sure that it is the same problem on OSX. I found the that the PEAR install created the wrong path in the batch file used to launch the program.
The standard install causes the installed batch files to have errors. The final script line of the pear.bat batch file needs to have the include_path wrapped in single quotes ("include_path='%VARIABLE%'").
The change I made is:
"%PHP_PEAR_PHP_BIN%" -C -d memory_limit="-1" -d safe_mode=0 -d register_argc_argv="On" -d auto_prepend_file="" -d auto_append_file="" -d variables_order=EGPCS -d open_basedir="" -d output_buffering=1 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -f "%PHP_PEAR_INSTALL_DIR%\pearcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9
I am not sure if you have a similar problem to the one above for your install.
Failing that, my batch file for PHPUnit on Windows 7 is
if "%PHPBIN%" == "" set PHPBIN=C:\Program Files (x86)\PHP\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\Program Files (x86)\PHP\phpunit" %*
A less invasive way (without changing the php.ini permanently) is to include the following line in the script that fails: set_include_path("/opt/local/lib/php/");
The location you are including might be slightly different. If this doesn't work, search for a file called Autoload.php that is in a folder structure like this: File/Iterator/Autoload.php and use the path to File as the path in set_include_path().

Categories