CakePHP 3.8博客教程错误:控制器正在关闭

问题描述 投票:0回答:1

嗨,我遵循了本教程:https://book.cakephp.org/3/en/tutorials-and-examples/blog/part-two.html,尝试访问链接时遇到问题:localhost / myprojectname / articles / indexlocalhost / myprojectname / articles / view / 1

这是屏幕截图:Error:Missing Controller

我正在使用XAMPP和Chrome浏览器。文章模型,文章控制器和文章视图是按照教程中的说明创建的。但是,当我尝试访问localhost / myprojectname / articles / index上的链接时,缺少控制器错误,如上面的屏幕快照所示。

但是,在商品控制器和商品模型文件的顶部插入<?php之后,仍然显示与该屏幕截图相同的缺少控制器错误:Error: Missing Controller 2

php cakephp cakephp-3.0
1个回答
0
投票

将其复制并粘贴到您的AppController:

<?php

namespace App\Controller;

class ArticlesController extends AppController
{
    public function index()
    {
        $this->set('articles', $this->Articles->find('all'));
    }

    public function view($id = null)
    {
        $article = $this->Articles->get($id);
        $this->set(compact('article'));
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.