use*_*486 7 php authentication cakephp cakephp-3.0
我对cakephp ver3.1.3没有经验
我按照说明实现了登录验证功能; http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html
我设法成功蛋糕烘焙我的cakephp v3.1.3应用程序.
我有一个UsersController.php的问题
我从http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html复制并粘贴了以下代码;
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Allow users to register and logout.
// You should not add the "login" action to allow list. Doing so would
// cause problems with normal functioning of AuthComponent.
$this->Auth->allow(['add', 'logout']);
} //public function beforeFilter(Event $event)
Run Code Online (Sandbox Code Playgroud)
此代码的存在产生了以下错误;
严格(2048):App\Controller\UsersController :: beforeFilter()的声明应与App\Controller\AppController :: beforeFilter(Cake\Event\Event $ event)兼容[APP/Controller\UsersController.php,第12行]代码上下文包括 - APP/Controller\UsersController.php,第12行Composer\Autoload\includeFile - ROOT\vendor\composer\ClassLoader.php,第412行Composer\Autoload\ClassLoader :: loadClass() - ROOT\vendor\composer\ClassLoader .php,301行spl_autoload_call - [内部],行?? class_exists - [内部],行?Cake\Core\App :: _ classExistsInBase() - CORE\src\Core\App.php,第89行Cake\Core\App :: className() - CORE\src\Core\App.php,第66行Cake\Routing\Filter\ControllerFactoryFilter :: _ getController() - CORE\src\Routing\Filter\ControllerFactoryFilter.php,第81行Cake\Routing\Filter\ControllerFactoryFilter ::
如果我删除有问题的代码段,则错误消失.代码段有什么问题?
use*_*486 27
解决方案是将以下行添加到UsersController.php
use Cake\Event\Event;
Run Code Online (Sandbox Code Playgroud)
蛋糕烘焙版没有上述行.
在 Cake 4.0.2 Strawberry 上 - 现在是 -
use Cake\Event\EventInterface;
public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5010 次 |
| 最近记录: |