cakephp controller not found error on production server

十年热恋 提交于 2019-12-11 06:29:58

问题


I have a cakephp project under folder FC such that on ubuntu, it's path is /var/www/FC/app/... Upon uploading to ec2 and making all configuration changes, the base path, ie. index.php is correctly opening but any other link on index.php is giving an error:

Error: FCController could not be found.

Error: Create the class FCController below in file: app/Controller/FCController.php

class FCController extends AppController {

}

Upon creating this file, it asks to put method locations into the class FCcontroller, and on putting an empty method in the class, the display goes blue like an empty page. Since I haven't written this code I have no clue where the data which should be here is written...what should I Do?


回答1:


You need to alter these three lines in your app\webroot\index.php:

// The full path to the directory which holds "app", WITHOUT a trailing DS.
define('ROOT', '/var/www/FC');

// The actual directory name for the "app".
define('APP_DIR', 'app');

// The absolute path to the "cake" directory, WITHOUT a trailing DS.
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');

to point to their respective locations.

(the last of the three is commented by default, so you'll need to uncomment it.




回答2:


i sorted the issue out. It was because in my code, the previous user had made a controller file Locationscontroller.php and specified urls like this:

<form id ="0" action="/FC/locations/confirm_final">

This was for localhost in my local machine where the base folder was htdocs I had to type localhost/FC/ to access index.php. So naturally Since on EC2 I had made FC itself my base folder, it was trying to access another FC inside it which didn't exist. The /XXX/locations/ means it searches for "XXX" controller and then locations inside it. Since my controller was Locations, it kept giving an error.

As soon as I changed it to this:

<form id ="0" action="/locations/confirm_final">

It pointed to the right controller which was locations. It was all because I didn't check which controller was called by which View! I'm an idiot, that'll be all :D



来源:https://stackoverflow.com/questions/18547869/cakephp-controller-not-found-error-on-production-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!