6

I am working in php project, its giving the error as:

Warning: 

require_once(ROOT_PATH/lib/confs/Conf.php) [function.require-once]: failed to open stream: No such file or directory in ..\htdocs\GProject\lib\exception\ExceptionHandler.php on line 20

Fatal error: require_once() [function.require]: Failed opening required 'ROOT_PATH/lib/confs/Conf.php' (include_path='.;C:\php5\pear') in ..\htdocs\GProject\lib\exception\ExceptionHandler.php on line 20

But in \ExceptionHandler.php file, the 20th line is

require_once ROOT_PATH . '/lib/confs/Conf.php'; 

And I have the file Conf.php under the lib/confs/Conf.php itself, even though I am getting the error.

What may be the problem. Thanks in advance.

1
  • Can you show the code that defines ROOT_PATH? Commented Apr 13, 2011 at 9:32

4 Answers 4

7

I would go through the following assumptions debugging this,

  1. The file doesn't exist.
  2. The ROOT_PATH is incorrectly set.
  3. The current working directory isn't what is expected, so if ROOT_PATH is relative, it's breaking the full path.

If none of the above is the case, I'm not sure.

Some libraries must be installed into a directory that is listed in PHP's library path. In these situations you have a few options:

  • Install the library into a directory searched by PHP by default (e.g., /usr/share/php).
  • Update the include path using set_include_path without overwriting the old path (use get_include_path in combination with PATH_SEPARATOR).
Sign up to request clarification or add additional context in comments.

Comments

2

ROOT_PATH is not defined in your script. This should be a defined constant with the value of your root path.

Check it if it is defined or not.

if (defined('ROOT_PATH')) { echo 'Defined';} else { echo 'Not defined'; } 

It is not defined.

If it was defined then your error message will contain the value of defined constant since it contains the constant itself in error.

Define in your script.

define('ROOT_PATH',$_SERVER['DOCUMENT_ROOT']); //an example 

OR you have forgot to include the configuration file in which these constant are defined.

Comments

1

Just do an echo of the whole path you pass to the require_once function and carefully check if there is something wrong with it :

echo ROOT_PATH . "/lib/confs/Conf.php"; 

Comments

0

I ran into this problem today. I found the answer. PHP Bug #23392

Basically you have to install the Pear OLE extension.

pear install OLE

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.