Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to add admin prefix in CakePHP 3.0 version ?
If we want to add admin prefix in our CakePHP web application then firstly we have to use CakePHP 3.0 version because we can not add admin prefix in CakePHP 2.* version.
we can easily add admin prefix in our CakePHP web application just write the following lines in core.php.
<?php Configure::write('Routing.prefixes', array('admin')); ?>
Also we have to write below code to enable cakephp 3.0 in app/config/routes.php
<?php
Router::prefix('admin', function($routes) {
$routes->connect('/', ['controller'=>'Users','action'=>'login']);
$routes->fallbacks('InflectedRoute');
});
?>
Now we have will create Admin folder inside Controller src:
src/Controller/Admin/UsersController.php
And add following lines of code in UsersController.php
namespace App\Controller\Wcbadmin;
Now we will create the view file:
src/Template/Admin/Users/login.ctp
I hope this blog will help you.
thanks
0 Comment(s)