CodeIgniter Forums
Group routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Group routing (/showthread.php?tid=76811)



Group routing - shyam_samtan - 06-22-2020

What should be the folder structure and controller class name for group routes as example:

$routes->group('admin', function($routes)
{
    $routes->add('users', 'Admin\Users::index');
    $routes->add('blog', 'Admin\Blog::index');
});


RE: Group routing - inumaru - 06-23-2020

Folder structure will be the same as the second parameter,
like this in your case;


Code:
app/Controllers/Admin/Users.php
app/Controllers/Admin/Blog.php


as for the controller file itself the content will be something like this:


PHP Code:
<?php namespace App\Controllers\Admin;

class 
Users extends Controller
{
    public function 
index()
    {
        //your code goes here----------
    
}




RE: Group routing - shyam_samtan - 06-24-2020

(06-23-2020, 12:19 PM)inumaru Wrote: Folder structure will be the same as the second parameter,
like this in your case;


Code:
app/Controllers/Admin/Users.php
app/Controllers/Admin/Blog.php


as for the controller file itself the content will be something like this:


PHP Code:
<?php namespace App\Controllers\Admin;

class 
Users extends Controller
{
    public function index()
    {
        //your code goes here----------
    }


Thanks a lot @inumaru