0

I have moved an old cakephp site (2011) to a new provider and the site is not functional.. I have errors like

Warning: include(Cake/bootstrap.php): failed to open stream: No such file or directory in /home/toussacfuq/www/app/webroot/index.php on line 77

Warning: include(Cake/bootstrap.php): failed to open stream: No such file or directory in /home/toussacfuq/www/app/webroot/index.php on line 77

Warning: include(): Failed opening 'Cake/bootstrap.php' for inclusion (include_path='/home/toussacfuq/www/lib:.:/usr/local/php5.4/lib/php') in /home/toussacfuq/www/app/webroot/index.php on line 77

Fatal error: CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your /cake core directory and your /vendors root directory. in /home/toussacfuq/www/app/webroot/index.php on line 88

can you help please ? thank you

Madhawa Priyashantha
  • 9,633
  • 7
  • 33
  • 60
  • 1
    What is the value of `CAKE_CORE_INCLUDE_PATH`? Have you checked that it is set to the new server path `/home/toussacfuq/www/app/webroot` or is it still set to your old hosting path? – Peter HvD Sep 10 '18 at 12:11
  • I would suggest using `$_SERVER['DOCUMENT_ROOT']` in your path, because it always makes sure that you are starting from the root of your server directory. This is also great, because it doesn't care whether you change host and whatnot. As long as your directory structure follows whatever comes afterwards, then it will open/find the files correspondingly. Example: `include($_SERVER['DOCUMENT_ROOT'].'/path/to/file');`. it also makes everything easier by not using `../../../` which is tedious (to say the very least) to keep track of. – Martin Sep 10 '18 at 12:22

1 Answers1

0

It looks like you have a variable containing a customized path. Since you are moving to a different host, make sure that path is still relevant.

One thing I would suggest however, is to use $_SERVER['DOCUMENT_ROOT'] instead of hardcoded file paths. This will work at all times, and it doesn't matter if you change host. $_SERVER['DOCUMENT_ROOT'] will always make you start of your web servers root directory. This is way better than having the same functionality hardcoded, because in the case of a hardcoded path, you will encounter the problem that you are facing right now.

When using file paths, I would also recommend that you ALWAYS start from your root directory. It's simply easier to navigate when looking through your own code, wondering what is where. Especially if your directory is/becomes of a certain size. Things like ../../../ makes it incredibly hard to follow the directory paths by just looking at it and understand how everything is connected.

An example using $_SERVER['DOCUMENT_ROOT'] would be:

include($_SERVER['DOCUMENT_ROOT'].'/path/to/file');

This will always work, as long as you make sure that whatever path you define after the $_SERVER['DOCUMENT_ROOT'] is correct, and it will save you a lot of trouble in the future, such as the problems you are facing right now.

Martin
  • 2,326
  • 1
  • 12
  • 22
  • Hi, I saw that many files were missing on the server.. so I dowloaded again the old site and uploaded the files to the new server. I corrected some files and the credentials of the database.. The error now is Fatal error 256.. – Patrick Sep 11 '18 at 12:26
  • Fatal Error (256): [CakeSessionException] Unable to configure the session, setting session.auto_start failed. #0 /home/toussacfuq/www/lib/Cake/Model/Datasource/CakeSession.php(186): CakeSession::_configureSession() #1 /home/toussacfuq/www/lib/Cake/Model/Datasource/CakeSession.php(213): CakeSession::start() #2 /home/toussacfuq/www/lib/Cake/View/Helper/SessionHelper.php(122): CakeSession::check('Message.flash') #3 /home/toussacfuq/www/app/View/Layouts/default.ctp(45): SessionHelper->flash() #4 /home/toussacfuq/www/lib/Cake/View/View.php(910).. and more lines.. – Patrick Sep 11 '18 at 12:29
  • Try refer to: https://stackoverflow.com/questions/3245417/cake-php-fatal-error-256 – Martin Sep 11 '18 at 13:15
  • well, after many files modified, the site is working.. some errors because of PHP 5.4 compatibility. Thanks for helping ! – Patrick Sep 11 '18 at 13:35
  • No problem. :) Consider accepting an answer if you believe it pointed you in the right direction. – Martin Sep 11 '18 at 13:36