zend-framework - 无法使用 Zend Framework 制作静态页面(关于我们)

标签 zend-framework frameworks static

我正在尝试使用 Zend Framework 制作一个网站,因为我听说它非常好并且我想尝试使用框架,但我有一个简单的问题让我发疯。

我想用静态内容制作一个简单的 mywebsite.com/about 页面,因为除了显示 html 之外不需要做任何其他事情。

我制作了一个 About Controller ,与它关联的 phtml,但是当我尝试转到/about 时,我收到 404 错误,然后是:

The requested controller could not be mapped to an existing controller class.

Controller:
not-found(resolves to invalid controller class or alias: not-found)

所以我检查了我的路由文件:

'router' => array(
    'routes' => array(
        'about' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/about',
            ),
            'defaults' => array(
                'controller' => 'About\Controller\About',
                'action' => 'index',
            ),
        ),
    ),
),

所以如果我没记错的话,这应该会调用我制作的 About Controller ,但无法找到问题所在。

如果有人可以帮助我了解我错过了什么或者我没有得到 Zend,我会很高兴。

编辑:Zend 的版本是 2.x,如果有任何改变的话

#

编辑 2:感谢 James Kent 的帮助,我找到了解决方案

我的路由文件似乎有误,这是新的:

    'router' => array(
    'routes' => array(
        'about' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/about',
                'defaults' => array(
                    '__NAMESPACE__' => 'About\Controller',
                    'controller'    => 'About',
                    'action'        => 'index',
                ),
            ),
        ),
    ),
),

我还必须更改我的关于 Controller 的 indexAction:

class AboutController extends AbstractActionController
{
public function nolayoutAction() {
    $viewModel = new ViewModel();
    //$viewModel->setTerminal(true); Uncomment to disable the layout
    return $viewModel;
}

public function indexAction()
{
    $viewModel = $this->nolayoutAction();
    return $viewModel;
}
}

我希望它能帮助一些人。

最佳答案

据我所知,这样的事情应该可行:

$route = new Zend_Controller_Router_Route_Static(
    'about',
    array('controller' => 'about')
);
$router->addRoute('about', $route);

与此同时,我将查找我最初了解此内容的文档。

编辑:事实证明,您可能需要的是自定义路由,它们的文档已结束 here .

关于zend-framework - 无法使用 Zend Framework 制作静态页面(关于我们),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12919458/

相关文章:

php - node.js 中的作业队列

php - Zend Framework 在插入之前是否锁定表?

asp.net-mvc - ASP.NET MVC Controller 静态方法

PHP 加速器和静态字段

java - 以静态方式访问还是通过参数访问?

php - 有没有办法从 Zend-framework 的查询中获取记录数?

php - Doctrine 1.2 Pager - 它是否减少了从数据库请求的数据量

asp.net - 更新 web.config 中的值

ios - 架构 armv7 iOS 7.0 的 undefined symbol

layout - 我们应该使用 CSS 框架吗?他们值得吗?