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.
Related
I used composer install in the folder C:\xampp\htdocs\PhpstormProjects, exactly where my website files are located. Now, when I want to view the local version of my files at http://kabel.local.dev:8080, I'm getting these errors:
Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\PhpstormProjects\www\index.php on line 14
Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\PhpstormProjects\www\index.php on line 14
I am probably using the wrong path but I'm not sure which path I should use? I tried C:\xampp\htdocs\PhpstormProjects\vendor but my cmd says that doesn't contain composer.json, the cmd tells me
No composer.json in current directory, do you want to use the one at C:\xampp\htdocs\PhpstormProjects? [Y,n]?
Is your vendor folder in C:\xampp\htdocs\PhpstormProjects\ ?
If yes, you have to execute composer update in your C:\xampp\htdocs\PhpstormProjects\www\ folder.
By default, you have to execute composer commands at the same location where your index.php is located.
OR you can change in your index.php the line
require_once('vendor/autoload.php');
to
require_once('../vendor/autoload.php');
In your index.php file, try update the line 14 of
require_once('vendor/autoload.php');
to
require_once('vendor'.DIRECTORY_SEPARATOR.'autoload.php');
If this not work, please, send for us an picture for the folder structure or an snippet of your index.php
Hello i'm running WAMP (32 Bit) server
i exec C:\wamp\www\1\index.php using browser with this address http://localhost:8080/1/
index.php has the follow code
require_once 'libraries/database/database.php';
database.php has the follow code
require_once '../misc/traits/singleton.php';
singleton.php is located in this location
C:\wamp\www\1\libraries\misc\traits\singleton.php
database.php is located in this location
C:\wamp\www\1\libraries\database\database.php
and there is error(s):
( ! ) Warning: require_once(../misc/traits/singleton.php): failed to open stream: No such file or directory in C:\wamp\www\1\libraries\database\database.php on line 3
( ! ) Fatal error: require_once(): Failed opening required '../misc/traits/singleton.php' (include_path='.;C:\php\pear') in C:\wamp\www\1\libraries\database\database.php on line 3
Thanks
Paths stem from the php file that was originally executed, unless you change the path using chdir.
So use 'libraries/misc/traits/singleton.php'
If you want to do relative includes, use __DIR__, which is the directory of the CURRENT file.
e.g.
__DIR__ . '/../misc/traits/singleton.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?
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.
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.