I am working on ubuntu 12.04. I installed HTTP_Client by sudo pear install HTTP_Client. But when I am using require_once 'HTTP/Client.php';. It's showing:
Warning: require_once(HTTP/Client.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /var/www/mai.php on line 3
How I remove this error?
How paths are resolved when using include or require is controlled by the include_path php.ini setting, which is typically set to:
include_path=".:/usr/share/php"
Whereby /usr/share/php points to where PEAR is installed.
It can be set using set_include_path() during runtime as well:
set_include_path(".:/usr/share/php");
Should be run before you include anything else.
'HTTP/Client.php' is a relative path. The error message means that the file doesn't exist at that location. You'll need to modify the path, or move the file.
In this case your PHP file is in "/var/www/" and there is no HTTP directory there.
Edit: I would recommend modifying the path to be the full path rather than the relative path:
require_once 'HTTP/Client.php';
Change to:
require_once '/usr/share/php/HTTP/Client.php';
Related
Run dev_appserver.py and now get an error relating to curl.so:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\dev\google-cloud-sdk\platform\google_appengine\php\php-5.5-Win32-VC11-x86\curl.so' - The specified module could not be found.
This file does appear to be missing from the directory specified but haven't touched anything and have not had this error before.
How do I resolve?
Additional info
I have found there is already a php.ini file in same directory as app.yaml, just a few basic lines:
extension = "curl.so"
;extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
So I changed it to comment out the first line and restore the second line:
;extension = "curl.so"
extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
The error now changes to cant find ...php_curl.dll.
Yet the file seems to be there:
So why the error now? seems the path to dll is correct.
If you want to use Curl and not Curl Lite, then you need to reference the .dll version while using a Windows based system. Create a php.ini file in the same directory as your app.yaml file add the following line to it:
extension = php_curl.dll
If instead you want to use curl lite, you can remove the line above and instead add:
google_app_engine.enable_curl_lite = "1"
to the php.ini file.
I need to emails from my PHP script. The Server, which I have hosted my website on, does not allow the use of core PHP mail() function. They say I should write SMTP authentication code for sending emails.
I need to use require_once('System.php'); at the beginning of my PHP script, but the script execution stops beyond this line. In Apache logs of the Server, the log entry says:
AH01071: Got error 'PHP message: PHP Warning: require_once(): open_basedir restriction in effect. File(/opt/plesk/php/5.6/share/pear/System.php) is not within the allowed path(s): (/var/www/vhosts/kbcsurveyors.com/:/tmp/) in /var/www/vhosts/kbcsurveyors.com/preinspection.kbcsurveyors.com/test-smtp-mail.php on line 20\nPHP message: PHP Warning: require_once(/opt/plesk/php/5.6/share/pear/System.php): failed to open stream: Operation not permitted in /var/www/vhosts/kbcsurveyors.com/preinspection.kbcsurveyors.com/test-smtp-mail.php on line 20\nPHP message: PHP Fatal error: require_on................
kbcsurveyors.php is the domain that I have hosted.
For SMTP authentication, I need to use PEAR. I had to include the path/to/pear in the php.ini on the Server. Since, the Server does not allow me to change its own php.ini, I copied it to my domain's folder and appended the path/to/pear to include_path.
Here are commands I used and outputs I had from those commands:
shell_exec('cp /opt/plesk/php/5.6/etc/php.ini /var/www/vhosts/kbcsurveyors.com/httpdocs/includes');
shell_exec('pear config-get php_dir');
OUTPUT: /usr/share/pear
shell_exec('php --ini');
OUTPUT:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/00-ioncube-loader.ini,
/etc/php.d/curl.ini,
....
echo get_include_path();
OUTPUT .:/opt/plesk/php/5.6/share/pear
echo 'Class Exists: '.(class_exists('System', false)) ? 'Yes' : 'No';
OUTPUT: Class Exists: Yes
But again, require_once 'System.php'; throws the above error in Apache log.
The phpinfo()ed a script. It shows the include_path as .:/opt/plesk/php/5.6/share/pear in both Local Value and Master Value.
What mistake am I making? Please help.
Thanks in advance
The problem was solved by appending the path shown by
shell_exec('pear config-get php_dir'); to include_path in php.ini of primary domain and all sub-domains.
Am having this error as i installed my pear package and to run the Numbers to word class.
Warning: include(Numbers/Words.php): failed to open stream: No such file or directory
and this is my php.ini file include string
; Windows: "\path1;\path2"
include_path = ".;c:\php\includes;c:\php\pear"
Please i need help...it has taken most of my time here..
Try to add this line
include_path = ".;C:\wamp\bin\php\php5.5.12\pear"
Edit:
Here are docs:
http://pear.php.net/manual/en/installation.checking.php#installation.checking.cli.modifyingphpini
I'm trying to set the session.save_path on my IIS/PHP via fastcgi server. So I created a new folder called tmp in my php folder, gave IUSR and IIS_IUSRS full permissions to this folder, and set my session.save_path variable in php.ini to "\tmp".
Upon loading my webpage I get the error:
Warning: session_start(): open(tmp\sess_gp13t5fg969iddfq1lrt3e88o1, O_RDWR) failed: No such file or directory (2)
The weird thing is I know it can see the folder because I look in my newly created tmp folder and it actually created the sess_gp13t5fg969iddfq1lrt3e88o1 file right before throwing the error telling me it doesn't exist. So how can it create the file and then not see it? What could I be doing wrong?
Update: If I set session.save_path with an absolute path, it works. When I give it a relative path of just "\tmp" it no longer works. Every example I see uses a relative path for the save_path and I personally need to use a relative path. Why would a relative path cause this issue and how do I fix it?
I found the answer you seek:
Relative Paths in PHP
include($_SERVER["DOCUMENT_ROOT"] . "/relative path here");
Under linux the PrivateTmp config of systemd may be the problem.
The solution would be to copy the corresponding systemd unit file to /etc/systemd and remove there the privatetmp config.
In my case:
cp /usr/lib/systemd/system/httpd.service /etc/systemd/system
systemctl daemon-reload
systemctl restart httpd.service
Change in /etc/systemd/httpd.service then
PrivateTmp=true
to
PrivateTmp=false
I am trying to include a php file from the parent directory and I getting error:
admin#webby:~$ /usr/bin/php
/var/phpscripts/email_parser/tests/_email-test.php PHP Fatal error:
require_once(): Failed opening required '../PlancakeEmailParser.php'
(include_path='.:/usr/share/php:/usr/share/pear') in
/var/phpscripts/email_parser/tests/_email-test.php on line 6
Fatal error: require_once(): Failed opening required
'../PlancakeEmailParser.php'
(include_path='.:/usr/share/php:/usr/share/pear') in
/var/phpscripts/email_parser/tests/_email-test.php on line 6
PHP file
#!/usr/bin/php
<?php
error_reporting(E_ALL ^ E_NOTICE ^E_WARNING);
ini_set("display_errors" , 1);
require_once("../PlancakeEmailParser.php");
// etc
?>
Folder Structure
admin#webby:/var/phpscripts/email_parser$ find .
.
./composer.json
./README.txt
./LICENSE.txt
./PlancakeEmailParser.php
./tests
./tests/_email-test.php
For testing it works fine when I move PlancakeEmailParser.php into the tests directory and remove the "../" from the require
The line
require_once("../PlancakeEmailParser.php");
Is not using a fully qualified file-system path or PHP-URI-scheme. Therefore its outcome depends on PHP configuration, most often because of the include directory configuration.
The PHP CLI can use a different configuration file than with your webserver - or - the working directory is different as with your webserver (probably the later plays more of a role in your specific scenario).
What you want can be easily expressed fully qualified, too:
require_once(__DIR__ . "/../PlancakeEmailParser.php");
This is probably what you're looking for.
Quote from PHP CLI SAPI: Differences to other SAPIs:
It does not change the working directory to that of the script. (-C
and --no-chdir switches kept for compatibility)
In order to keep relative paths in your script working as-is, change directory to where the script resides, then execute the script:
cd /var/phpscripts/email_parser/tests/ && ./_email-test.php