Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How To Do Administration Prefix Routing with Cakephp 3?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.98k
    Comment on it

    To map the URL controller action the feature that is used is routing and in CakePHP to make URLs more configurable and flexible routing is introduced. So in this tutorial we will see the process of Administration Prefix Routing with Cakephp 3.

    In Cakephp 2 administration  prefix routing is done in the following way:

    Configure::write('Routing.prefixes', array('admin'));

     

    In Cakehp 3, I was facing the issue to get the prefix routing work. Follow these steps :

    In config/routes.php - add the following lines at the end of the routes.php file

    Router::prefix('Admin', function ($routes) { $routes->fallbacks('InflectedRoute'); });

    Now create new folder 'Admin' in src/Controller. Then in Controller folder create UsersController. Add the following line as a namespace at the first line in the file

    namespace App\Controller\Admin;

    Create the views.

    In the Template folder create Admin folder. In the Admin folder create Users folder and dump all the add.ctp, edit.ctp, view.ctp files.

    Thats all !

     

    Thanks for reading the blog.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: