php - Declaration of UsersController::beforeFilter() should be compatible with AppController::beforeFilter(Cake\Event\Event $event) -


i not experienced cakephp ver3.1.3

i followed instructions implement login authentication function; http://book.cakephp.org/3.0/en/tutorials-and-examples/blog-auth-example/auth.html

i managed cake bake cakephp v3.1.3 app.

i have problem userscontroller.php

i have following code copied , pasted 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 register , logout.     // should not add "login" action allow list. doing     // cause problems normal functioning of authcomponent.     $this->auth->allow(['add', 'logout']); } //public function beforefilter(event $event) 

the presence of code created error below;

strict (2048): declaration of app\controller\userscontroller::beforefilter() should compatible app\controller\appcontroller::beforefilter(cake\event\event $event) [app/controller\userscontroller.php, line 12] code context include - app/controller\userscontroller.php, line 12 composer\autoload\includefile - root\vendor\composer\classloader.php, line 412 composer\autoload\classloader::loadclass() - root\vendor\composer\classloader.php, line 301 spl_autoload_call - [internal], line ?? class_exists - [internal], line ?? cake\core\app::_classexistsinbase() - core\src\core\app.php, line 89 cake\core\app::classname() - core\src\core\app.php, line 66 cake\routing\filter\controllerfactoryfilter::_getcontroller() - core\src\routing\filter\controllerfactoryfilter.php, line 81 cake\routing\filter\controllerfactoryfilter::beforedispatch() - core\src\routing\filter\controllerfactoryfilter.php, line 49 cake\routing\dispatcherfilter::handle() - core\src\routing\dispatcherfilter.php, line 145 cake\event\eventmanager::_calllistener() - core\src\event\eventmanager.php, line 389 cake\event\eventmanager::dispatch() - core\src\event\eventmanager.php, line 355 cake\routing\dispatcher::dispatchevent() - core\src\event\eventdispatchertrait.php, line 78 cake\routing\dispatcher::dispatch() - core\src\routing\dispatcher.php, line 62 [main] - root\webroot\index.php, line 37

if remove offending code segment, error disappears. wrong code segment?

the solution add following line userscontroller.php

use cake\event\event; 

the cake baked version not have above line.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -