CodeIgniter Forums
Database driven routing in CodeIgniter 2.x - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: Database driven routing in CodeIgniter 2.x (/showthread.php?tid=82631)



Database driven routing in CodeIgniter 2.x - EdwardSMaTeresa - 08-02-2022

I am creating a site that will have a lot of routes that will need to be added to the routes file (800+) - obviously I do not want to manually add these one by one into the routes config file.

Can anyone suggest the best practice to have my routes loaded automatically from the database. Is there a suitable library/helper that will perform this task that works with version 2.x

For instance..

$route['apple'] = 'brands/index';
$route['blackberry'] = 'brands/index';
$route['htc'] = 'brands/index';
$route['samsung'] = 'brands/index';
These are just a few of the brands i'd be adding to the routes - but there are hundreds of these so i'd want to have this loaded from a database rather than manually type these in. Also - would this method have any impact on site performance having them load from the database?

I am using Codeigniter v2.1.3


RE: Database driven routing in CodeIgniter 2.x - InsiteFX - 08-03-2022

I would upgrade to the new Codegniter 4, that version of CodeIgniter is out dated and
has lots of security bugs in it.


RE: Database driven routing in CodeIgniter 2.x - tgix - 08-03-2022

Wouldn't that design also make caching PHP-code with opcache impossible, reducing speed?