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(..){..})
router.post('/welcome', function(..){..})
router.put('/welcome', function(..){..})
router.delete('/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 {
public function __construct()
{
parent::__construct();
// Default route method: METHOD_index
$this->set_method('index');
}
public function set_method($method)
{
$request_method = $_SERVER['REQUEST_METHOD'] . '_';
$this->method = $request_method . $method;
}
}
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)