CakePHP的缺失控制器

CakePHP的缺失控制器

本文介绍了CakePHP的缺失控制器 - 但它的存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近下载CakePHP的-1.3.4。我将它设置我的Web服务器上。我跟着先进的安装设置。我的文件夹结构如下:

I recently downloaded cakephp-1.3.4. I set it up on my web server. I followed the advanced installation settings. My folder structure is as follows.

/common/
  cakephp/
     app/
     etc...
/htdoc/

/ htdoc 文件夹是根目录; CakePHP的位于通用文件夹中。

The /htdoc folder is the webroot; cakephp resides in the common folder.

我在index.php文件配置的路径指向这个文件夹结构。我有应用程序启动和运行。我创建了一个布局,应用程序已经把它捡起来(所有的CSS和图像一起 - 所有的作品)。

I have configured the paths in index.php to point to this folder structure. I have the app up and running. I created a layout, the app has picked it up (along with all the css and images - all that works).

创建一个 posts_controller.php 的CakePHP /应用/控制器/ 。现在,当我尝试访问以下页面:的。我得到控制器无法找到的消息,我应该创建一个应用程序/控制器/ posts_controller.php (它已经存在!)。

I created a posts_controller.php in cakephp/app/controllers/. Now when I try to access the following page: http://localhost/posts. I get a message that the controller cannot be found and that I should create a app/controllers/posts_controller.php (it already exists!).

另外,奇怪的是使用默认pages_controller 工作。我创建了一个about.ctp和应用程序/视图/页/ about.ctp 放弃了它。 Vising 显示为预期的

Also the strange thing is using the default pages_controller works. I created an about.ctp and dropped it in app/views/pages/about.ctp. Vising http://localhost/pages/about shows up as expected.

解决方案:

山姆帮我解决这个问题(见下面的长注释线程)。问题是我为我的根文件夹设置的相对路径。这把事情搞乱。解决的办法是直接设置的绝对路径或致电的真实路径您的相对路径才能被分解为正确的绝对路径。

Sam helped me solve this problem (see the long comment thread below). The problem was I had set relative paths for my ROOT folder. This messed things up. The solution is to either directly set an absolute path or call realpath with your relative path for it to be resolved into the right absolute path.

推荐答案

请确保您的控制器类名是否正确(应该是PostsController)和AppController的(不是绝对必要的,但良好的做法)。继承

Make sure your controller class is named correctly (should be PostsController) and inherits from AppController (not strictly necessary but good practice).

这篇关于CakePHP的缺失控制器 - 但它的存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 14:13