CodeIgniter Forums

Full Version: enable users to define their own routes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In CI3 application I've created a page to allow users to update routes, because it was so simple - I had to load and update an array only. 

Here I can see that it is not so simple any more. So can anyone suggest what is the best approach for me to enable users to update routes as they need?
You can map an entire array in CI4 as well.
https://codeigniter.com/user_guide/incom...ple-routes

But you need to write your own code get it there. Depending on how you do it, that can be a security risk, if you allow them to manipulate it without validation.
(08-16-2020, 07:16 AM)jreklund Wrote: [ -> ]You can map an entire array in CI4 as well.
https://codeigniter.com/user_guide/incom...ple-routes

But you need to write your own code get it there. Depending on how you do it, that can be a security risk, if you allow them to manipulate it without validation.

Thank you. So basically I can use the same Routes.php from CI3, I just need to load it and map it in CI4. Can you suggest the best place to store that PHP array file in CI4 for structure?
If your users change it from a GUI, you generally save it in the database, so you grab it from there. Or you save it as a JSON file that you grab from your Routes.php and load it.
(08-16-2020, 07:28 AM)jreklund Wrote: [ -> ]If your users change it from a GUI, you generally save it in the database, so you grab it from there. Or you save it as a JSON file that you grab from your Routes.php and load it.

My CMS is file based, so everything is saved in folders. So if it is a json file, where should I save it?
In a folder not accessible from any URL.
(08-16-2020, 08:52 AM)jreklund Wrote: [ -> ]In a folder not accessible from any URL.

OK, I can create a folder named for ie, "settings" under the app folder, and store configurable things there. Thanks so much for your support. I will continue using and promoting codeigniter.