CodeIgniter Forums
Bug in routes with path in controller - 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: Bug in routes with path in controller (/showthread.php?tid=74899)

Pages: 1 2


RE: Bug in routes with path in controller - paulkd - 05-14-2021

Thanks very much for your help everyone  Big Grin

This is how my routes are coming along...

Code:
$routes->get('about', 'Main::about', ['namespace' => 'App\Controllers\Front']);
$routes->get('contact-us', 'Main::contactUs', ['namespace' => 'App\Controllers\Front']);
$routes->get('products/(children|men|women)', 'Main::getProducts/$1', ['namespace' => 'App\Controllers\Front']);

I wanted to "group by namespace" but I don't think I can. If not, I will look to having a var for the namespace array.


RE: Bug in routes with path in controller - InsiteFX - 05-14-2021

You can use the namespace in a group route but all the routes under it should belong to that namespace.


RE: Bug in routes with path in controller - paulkd - 05-14-2021

(05-14-2021, 01:35 AM)InsiteFX Wrote: You can use the namespace in a group route but all the routes under it should belong to that namespace.

Hi InsiteFX,

Thanks very much for your help.  Big Grin

If I'm interpreting the group options correctly it looks like I can specify a group "namespace" but not a group "controller" under a group namespace.

So what I have at present is

Code:
$frontNameSpace = ['namespace' => 'App\Controllers\Front'];

$routes->get('/', 'Main::index', $frontNameSpace);
$routes->get('about', 'Main::about', $frontNameSpace);
$routes->get('products/(children|men|women)', 'Main::getProducts/$1', $frontNameSpace);
$routes->get('bag', 'Main::bag', $frontNameSpace);
$routes->get('checkout', 'Main::checkout/card', $frontNameSpace);

Do you think there's a better way to group these routes ?


RE: Bug in routes with path in controller - InsiteFX - 05-14-2021

You can also declare a controller in the group.

Mistake its the group name for like admin which would make the url admin/routeName.