include_path related problems in php - php

I have a PHP application where the autoloader is situated in /var/www/html/example.com/src/vendors/autoloader.php
var/
www/
html/
example.com
app/
vendors/
vendor_a/
example.php
vendor_b/
vendor_c/
autoloader.php
public/
In autoloader.php I have a line that requires example.php from the vedor_a/ folder.
although this works in my local virtual box running centos, php-fpm, nginx it fails to work in my vps, which has the same version of every program I am running in my localhost.
I am using php5.5.14
and I get this error when I require the above file.
Warning: require(vendor_a/example.php): failed to open stream: No such file or directory in /var/www/html/example.com/vendors/autoloader.php on line 2
Fatal error: require(): Failed opening required 'vendor_a/example.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/example.com/vendors/autoloader.php on line 2
I haven't modified anything from my php.ini where the include_path defaults to
; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
I am looking more than a solution here. Because I can see the include_path looks for php/includes dir when constructs such as require, include, include_once... at-least according to the manual but I can't find a directory called php/includes so why is that setting even there?

Related

Cannot include files from another folder

I have current directory structure htdocs/mvc2/ which includes app and public folders.
If i run bootstrap.php http://localhost/mvc2/app/core/bootstrap.php with require_once '../config/config.php' it's included, works fine.
If i try to include bootstrap.php in my http://localhost/mvc2/public/index.php
I'm getting the following errors:
Warning: require_once(../config/config.php): failed to open stream: No
such file or directory in C:\xampp\htdocs\mvc2\app\core\bootstrap.php
on line 2
Fatal error: require_once(): Failed opening required
'../config/config.php' (include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\mvc2\app\core\bootstrap.php on line 2
I can include bootstrap.php file in my index.php if i comment out all the includes in bootstrap.php file though:|.
Im using windows7 with xampp.
I have tried changing php.ini file as suggested by others having the same problem to no avail. It's currently:
; UNIX: "/path1:/path2"
include_path=C:\xampp\php\PEAR
; Windows: "\path1;\path2"
;include_path = ".;C:\xampp\php\pear"
open
C:\xampp\htdocs\mvc2\app\core\bootstrap.php
and edit this line
require_once('../config/config.php')
give the full path of this file config.php
you can use $_SERVER['DOCUMENT_ROOT'].'/YOUR_INCLUDEABLE_FILE_NAME';
$_SERVER['DOCUMENT_ROOT'] is The document root directory under which the current script is executing, as defined in the server's configuration file.
your server will return C:\xampp\htdocs by using $_SERVER['DOCUMENT_ROOT'].
hard coding the full path works.
Tried using $_SERVER['DOCUMENT_ROOT'].'/YOUR_INCLUDEABLE_FILE_NAME' in win10 the DOCUMENT_ROOT is showing "/" instead of "\". It fails.

Zend - error in index.php - not opening Zend/Application.php

I have a project written in PHP, in zend framework. But when i go on page: localhost/Project/public, i get an error:
Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/www/Project/public/index.php on line 18 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/var/www/Project/library:.:/usr/share/php:/usr/share/pear') in /var/www/Project/public/index.php on line 18
The line 18 in file index.php is following:
require_once 'Zend/Application.php';
I have set include_path in php.ini:
include_path = ".:/usr/share/php:/usr/local/ZendFramework/library"
Zf project is successfully creating by commands from console, so i think that Zend is well configured (anyway in php.ini).
Help me! What I'm doing wrong?
You can see the include path it's using in the error, and it doesn't include /usr/local/ZendFramework/library. Typically index.php overrides the include path to point it at the project's library folder. So either you want a copy of ZF in the library folder, or if you prefer to keep ZF in /usr/local/ you want to edit this include path to point at /usr/local/ZendFramework/library as well.

Zend Failed opening required 'Zend/Loader.php' on Plesk Server

I am getting the following warning and error on a plesk server where I am trying to get the Zend framework working:
PHP Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/vhosts/mydomain.com/httpdocs/test.php on line 5
PHP Fatal error: require_once() [function.require-once]: Failed opening required 'Zend/Loader.php' (include_path='.:/usr/share/pear:/local/PEAR/:/usr/share/zend') in /var/www/vhosts/mydomain.com/httpdocs/test.php on line 5
I have set the include_path in the php.ini file (/etc/php.ini) to use the directory where I have added the Zend files (/usr/share/zend). This directory then has the framework in a sub-dir called Zend.
I have tried adding a slash to the end of the include_path (/usr/share/zend/).
The path is present when I use get_include_path()
I have tried using set_include_path.
The /usr/share/zend directory has 775 permissions (also tried with 777) and the user and group are both set to root.
I would like to have the framework available to all sites on the server.
I have copied in the Gdata files too and the Zend/Loader.php is there.
Versions:
Framework: 2.0.4
Gdata: 1.12.0
This is the PHP:
require_once("Zend/Loader.php");
I have also tried using:
require_once("/usr/share/zend/Zend/Loader.php");
I am novice plesk/unix user
The things to check for are:
The file exists where PHP is looking for it.
The file is readable by the web server/php_fpm process.
safe_mode is off!
(Putting the information here - so that the question can be marked as answered!)
Zend/Loader.php is for ZF1 and that file don't exists with ZF2 (2.0.4)
Also you need to download the updated version of GData compatible with ZF2
https://github.com/zendframework/ZendGData
If you'll use Composer to setup your dependencies then you should use require_once __DIR__ . '/path/to/vendor/autoload.php

php.ini.default not finding new path to cloudfusion on Mac OS X Snow Leopard

I'm trying to follow along with a book on Amazon EC2 and it says to include a new file path in php.ini in the etc folder to the cloudfusion sdk. So I uncommented the path variable in php.ini.default and set the new path to be:
include_path = ".:/php/includes:/Users/john/cloudfusion"
but yet when I try running my php script inside a folder named amazon, it keeps giving me the error:
Warning: require_once(sdk.class.php): failed to open stream: No such file or directory in /Users/john/amazon/create_bucket.php on line 26
Fatal error: require_once(): Failed opening required 'sdk.class.php' (include_path='.:') in /Users/john/amazon/create_bucket.php on line 26
Anybody have any ideas?
PHP doesn't read php.ini.default, it just defaults to the values in it internally, to make sure your changes are read, you can copy that file to php.ini and edit your values.
Alternatively you can use http://nl3.php.net/ini_set function to modify your include path on-the-fly. You need to use ini_set before the actual require_once.

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).

Categories