Divide different type of requests |
Hello,
this idea comes from ExpressJS (on top of NodeJS). To define a route in ExpressJS you can do something like the following: Code: router.get('/welcome', function(..){..}) I really love this method division, since it helps keeping everything even more organised. Actually I have mocked this function creating MY_Router.php in application/core with the following: PHP Code: class MY_Router extends CI_Router { Now if I perform a GET request to /welcome/, the Class welcome will be loaded and the Method GET_index will be called. I think that it would be cool to have this feature in Codeigniter 4 (maybe with a settings that permits to enable and disable it) (05-13-2017, 08:18 AM)ciadmin Wrote: Sounds a lot like https://bcit-ci.github.io/CodeIgniter4/g...-in-routes Yeah, sort of. The difference is that with routing, a developer should add each page. If a site has 2 pages, like 'main' and 'contact', he should do something like: PHP Code: $routes->get('main/(:any)', 'GET_main/$1'); In my application I have 13 controllers, then my router would be something like 50 lines long. It is possible that I am loosing some special functions through. PS, I love the new routing in CI4, great work! (05-14-2017, 03:48 AM)mt19 Wrote: In my application I have 13 controllers, then my router would be something like 50 lines long. It doesn't sounds logical a framework to follow some personal needs (in that case yours). You can make grouping to your routes and with that to make it more clear or to use resources routes or to extend the router by yourself. Grouping https://bcit-ci.github.io/CodeIgniter4/g...ing-routes Resource routes https://bcit-ci.github.io/CodeIgniter4/g...rce-routes Those are helpful features .. Further if you have some specific logic of your routes in your mind you can follow the "resource" idea and to extend the Router with adding another method as resource() where you can register the group of routes which you have multiple times at your controllers... Best VPS Hosting : Digital Ocean
|
Welcome Guest, Not a member yet? Register Sign In |