I am working on a Laravel implementation of AggCatAuth. When I try to load the page (hosted on a homestead vm), I get the following error:
main(): Failed opening required 'class.aggcatauth.php' (include_path='.;C:\xampp\php\PEAR')
The class AggCatAuth is referenced in the following block with config.php
require_once('config.php');
require_once('class.aggcatauth.php');
Config.php loads fine, even though both files are in the same directory and have the same permissions.
What are some reasons that a required file would fail to open?
The error message refers to "include_path='.;C:\xampp\php\PEAR'". Which file within the laravel framework specifies the paths to include?
I have not found a single file that lists all the paths to include, but I was able to find the files which specify include paths using the grep command:
Grep -rl . -e "set_include_path"
Likewise the paths which are already included can be determined by running
Get_include_path()
Related
Im runninng lamp stack locally on my ubuntu 16.04 OS and Im getting problems when including files. My code in index.php:
<?php include('steamauth/steamauth.php'); ?>
<?php include('steamauth/userinfo.php');?>
my structure is:
index.php
steamauth
steamauth.php
userinfo.php
Im getting the following error:
include(steamauth/userinfo.php): failed to open stream: No such file or directory in /var/www/html/index.php
include(): Failed opening 'steamauth/userinfo.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/index.php
I tried using the full path , adding webroot before the path , changing include_path in php.ini , but nothing seemed to work . what do i do ?
Check folder pemission
Check that the Apache user has access to the include folder.
Check file permissions
Check that the permissions on the files that you are including can be read and executed by the Apache user.
Check PHP settings
It could be caused by one of the following PHP settings:
open_basedir:
If this is set PHP won't be able to access any file outside of the specified directory (not even through a symbolic link).
safe mode:
If this is turned on restrictions might apply.
Make path absolute
Check that $_SERVER["DOCUMENT_ROOT"] is correctly set for your domain by using:
print $_SERVER["DOCUMENT_ROOT"]; // Add to top of you index.php file.
Then change your includes to:
$_SERVER["DOCUMENT_ROOT"] . '/sub_folder/file_to_include';
Check for typos and spelling mistakes
Carefully check that what you think you have called the folder and what you are using to include it are spelt the same.
BTW: You can just use the following in your index.php file:
<?php
include('steamauth/steamauth.php');
include('steamauth/userinfo.php');
You also don't need to add the closing ?> at the end of the file - it's actually good practice not to.
Hi I am getting this error, when I run the index.php file which includes
require_once("system/config.php");
I am wondering what does this message mean, and how do I go about fixing such an issue. As this site worked fine when I ran it directly on my Mac.
require_once(): Failed opening required 'system/core.php' (include_path='.:/usr/share/php')
ALL THE BELOW ANSWERS ARE CORRECT!
However my issue was a CHMOD issue I had 644 instead of 744
It usually means you're trying to include the file with an incorrect path. What happens when you try the full path?
require_once(getcwd() . 'system/config.php');
The way your script is now, it's looking for the file with a directory structure like this:
file.php <- is calling the require_once()
- system <- the system directory
- config.php <- the config file
But this isn't the path where it's located.
The file system/core.php needs to be relatively to the file which is declaring the line require_once("system/core.php"); (that's system/config.php) or the direcory that contains system must be in your include_path. Search for core.php on your Mac. Check the configuration settings (include_path) on your Mac.
i run a cron job every night, but for some reason, it is saying that the file i try to include is inexistant:
Warning: require(../includes/common.php): failed to open stream: No such file or directory in /home/fini7463/public_html/cron/journeyNotifications.php on line 2
Fatal error: require(): Failed opening required '../includes/common.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fini7463/public_html/cron/journeyNotifications.php on line 2
here's the code:
set_include_path('/home/fini7463/public_html/includes/');
require 'common.php';
the file 'common.php' is located as follows
public_html => cron => journeyNotifications.php
=> includes => common.php
i even set the include path (as shown in the code), but i am still getting this error. what could the problem be?
thanks!
If you do require('../includes/common.php'), the path is traversed relative to the current working directory.
If you do require('common.php'), the file is searched in the include path, and in the directory of the script which calls the require().
To solve this, first change directory in your crontab:
cd /home/fini7463/public_html; php -f cronjob.php
Calling set_include_path() as you do trashes the previous path. The call replaces the previous path with whatever you're passing as an argument, so if any of your code loads other libraries (ie: PEAR/PECL modules), they'll no longer be accessible as you've trashed the include path. You should use:
set_include_path(get_include_path() . PATH_SEPARATOR . '/home/fini7463/public_html/includes/');
That will append your new path to the include path.
As well, you can never quite tell what the working directory will be when cron fires up your script. It could be the home directory of the user you're running the script as, could be /tmp, or some other directory entirely. If you want to use relative paths in the script for anything, you'll have to make sure the working directory is set to a known value. Either by using a 'cd' in the crontab, or using a 'chdir' inside the script before doing anything involving the relative paths.
When I use ../mysqlConnect.php I get the following messages.
Warning: require_once(../mysqlConnect.php) [function.require-once]:
failed to open stream: No such file or directory in /home/content/etc...
Fatal error: require_once() [function.require]: Failed opening required
'../mysqlConnect.php' (include_path='.:/usr/local/php5/lib/php') in /home/content/etc...
When I use the directory name - mydir/mysqlConnect.php - everything works fine.
require_once('../mysqlConnect.php') asks PHP to look in the directory above the one your script is currently in for mysqlConnect.php.
Since your connection file appears to be in a mydir directory, require_once('mydir/mysqlConnect.php') works because it looks in that directory, which is contained by the one it's currently in.
Visual representation (assuming script.php is your script including that file):
dir/
subdir/ # PHP looks here for ../mysqlConnect.php
script.php
mydir/ # PHP looks here for mydir/mysqlConnect.php
mysqlConnect.php
Require is relative to the invoced script, not the script you call require() in. Use something like this to have an absolute path:
require(dirname(__FILE__) . '/../mysqlConnect.php');
In PHP 5 you can also use DIR.
because it doesn't find your file then. to give a more specific answer I need to see you file-/folder-structure
That's because you are not specifying the correct include path. ../ refers to parent directory. ../../ goes two directories back, ../../../ goes three of them back. If the mysqlConnect.php file is present in the same folder as your script, you don't need to specify ../ in the include.
Make sure that you specify the correct path. You can easily check whether or not you are specifying correct path like:
if (file_exists('../mysqlConnect.php'))
{
echo 'Iam specifying the correct path !!';
}
else
{
echo 'Well, I am not :(';
}
I am trying to include the Zend_Service_Amazon_S3 file by using
require_once 'Zend/Service/Amazon/S3.php';
I have also included in the include path the directory where the entire Zend library is located, AND the installation is inside Zend Server CE (which includes the Zend Framework by default). However, no matter what I try, I only get the following for my troubles:
Fatal error: require_once() [http://php.net/function.require]: Failed opening required 'Zend/Server/Amazon/S3.php' (include_path='/usr/local/zend/apache2/htdocs:/usr/local/zend/apache2/htdocs/app/:.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear:/usr/local/zend/apache2/htdocs/app/vendors') in /usr/local/zend/apache2/htdocs/app/models/item.php on line 3
The Zend/Service/Amazon/S3.php is located under the paths:
/usr/local/zend/share/ZendFramework/library
/usr/local/zend/apache2/htdocs/app/vendors
Your error message says Zend/Server/Amazon/S3.php - Shouldn't it be Zend/Service/Amazon/S3.php?
Could it be the process that is running PHP does not have the required rights to read the file? Don't forget that a directory needs to be executable in order for a process to change to that directory (i.e. see the contents of its subfolders.)