我对cakephp更新鲜。对于我当前的项目,我使用的是CakePHP skeleton app
。一切都很顺利。但是当我为管理面板创建新控制器时,它会显示此消息Did you really think you are allowed to see that?
。有人请帮帮我。
我在下面显示我的代码:
路线:
Router::prefix('admin', function ($routes) {
// Other routes are here.
$routes->connect('/sections', ['controller' => 'Sections', 'action' =>'index']);
}
SectionsController.php
<?php
namespace App\Controller\Admin;
use App\Controller\AppController;
class SectionsController extends AppController {
public function index() {
echo "I am for sections page";
}
}
此控制器位于src\Controller\Admin
文件夹
以下是我的错误消息。
答案 0 :(得分:3)
可能这就是解决方案。
use Cake\Event\Event;
class YourController extends AppController
{
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->allow('index');
}
}