1

我在 my.phpcloud.com 上运行 Zend Framework 应用程序(所以服务器配置应该没问题...)

索引页面工作正常,我修改了 application/controllers/IndexController.php 如下:

class IndexController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this->view->assign('hello', 'hello world!');
    }
}

在 application/views/scripts/index/index.phtml 我打印 $this->hello 一切正常。

但是如果我创建一个新的控制器,比如 application/controllers/UserController.php

class UserController extends Zend_Controller_Action
{
    public function indexAction()
    {
        $this->view->assign('name', 'Albert');
    }
}

我在 application/views/scripts/user/index.phtml 中创建了视图,并像在索引视图中一样打印 $this->name。

但是当我访问时,http://myapp/user我得到一个 Not Found 错误......有什么问题?

4

1 回答 1

1

1) 检查用户控制器的文件名是否包含第一个大写字母 UserController.php(不是 userController.php)

2) 检查 .htaccess 文件是否有正确的重写规则

3)尝试http://myapp/User(用户大写首字母)

4) 检查是否启用了默认路由。

5)您是否创建并启用了错误控制器?

我认为配置中存在一些问题,可能在您的引导程序或 config.ini 中

于 2013-02-15T10:33:50.953 回答