3
votes

I encountered this error when trying to load my webpage.

The path that was showed on the error message was,

PHP Warning: include(/var/www/html/test.com/www/products/abc/lib/Cake/Error/ErrorHandler.php): failed to open stream:

It wasn't able to locate the Cake library directory as the path should be "/var/www/html/test.com/products/abc/lib/Cake/..." instead.

Any idea how I can fix this?

The error was pointing me to line 540 of the Core/App.php file which is,

if ($file = self::_mapped($className, $plugin)) {
        return include $file;   <<---- LINE 540
}
$paths = self::path($package, $plugin);

Thanks!

1
share your error screen shot or share your code of the webpage... for understand the reason betterAshish Raj
Check for your path, are you sure your path is valid /var/www/html/test.com/www/products/abc/lib/Cake/Error/ErrorHandler.php I doubt for test.com/www/...!!Tarunn
Can you give me a little more details about installation? Did you use composer?Asur

1 Answers

0
votes

Your CakePHP is trying to include a file just like if you typed

include '/var/www/html/test.com/www/products/abc/lib/Cake/Error/ErrorHandler.php';  

As mentioned in the PHP:include-Manual :

The include construct will emit a warning if it cannot find a file

The interesting thing here is that your CakePHP is missunderstanding your root directory, so an idea is that you have installed using a dependency manager such as Composer and moved your project into /var/www/html/test.com/www/ when was originally under the parent directory /var/www/html/test.com/.

In order to make sure, check the file where Cake defines its ROOT directory, which is the root index.php file. If you look inside you'll see something like this:

define('ROOT', dirname(__FILE__)); // <-- ROOT GLOBAL VARIABLE DEFINITION
define('WEBROOT_DIR', 'webroot');
define('WWW_ROOT', ROOT . DS . APP_DIR . DS . WEBROOT_DIR . DS);  

It can change with the version of the framework but it should be really similar.

The line that we are looking for is the first one, that means the ROOT global variable from CakePHP is set where the index.php is located.

My theory is that you have moved, deleted or modified the ROOT or other trascendent global variables and CakePHP is not finding the correct path as you posted.

If you need further information comment and I will edit this answer. Also a little bit more of information about your error will be appreciated so I can fit more your needs.
Hope this helped you :)