Welcome Guest, Not a member yet? Register   Sign In
Routes: Which style is "better"?

Since explicit routing became the recommendation a while back, I have wondered about the style of the route. Is there a "best practice"? Or is just developer preference?
Running CI 4.3.3 if it matters.
To illustrate, let's assume we have some controller ("lists") with a home page, an add record, an edit record and a report (super simple example, not real world). Is one of these better than the other?
$routes->match(['get', 'post'], 'lists/', 'Lists::index');
$routes->match(['get', 'post'], 'lists/add/(:any)', 'Lists::add/$1');
$routes->match(['get', 'post'], 'lists/edit/(:any)', 'Lists::edit/$1');
$routes->match(['get', 'post'], 'lists/report/(:any)', 'Lists::report/$1');

$routes->match(['get', 'post'], 'lists/', 'Lists::index');
$routes->match(['get', 'post'], 'lists/(:any)', 'Lists::$1');

With the various controls in my current project and being explicit for each function/page (like the first example), my routes file is now almost 650 lines. It can get confusing at times. Some of that is for various user permissions levels, but still quite long and could be cut by 75% going the other way I imagine.
I guess the root question is, "Is it better to be explicit for security or some other reason or is simple ok?".

Messages In This Thread
Routes: Which style is "better"? - by SoccerGuy3 - 12-27-2023, 11:55 AM
RE: Routes: Which style is "better"? - by demyr - 12-28-2023, 01:47 AM
RE: Routes: Which style is "better"? - by kenjis - 12-28-2023, 05:17 PM
RE: Routes: Which style is "better"? - by demyr - 12-29-2023, 02:43 AM
RE: Routes: Which style is "better"? - by lazcorp - 12-29-2023, 05:18 AM

Theme © iAndrew 2016 - Forum software by © MyBB