![]() |
i am not sure whether this should be a feature or a bug request. but ci4 doesnot truly allow autorouting at all.
for example if i decided to specify one route like below. $routes->group("instructor", function ($routes) { $routes->add("login", "Instructor\Instructor::login"); }); i no longer can access instructor/instructor/login or instructor/instructor/logout or any routes related to it. it throw this error. Cannot access the controller in a CLI Route. Controller: \App\Controllers\Instructor\Instructor in ci3 system was smart to figure out which controler based on the url. we can fix this if we go vendor/ci4/framework/system/router/autorouter.php and remove the line (if($this->httpVerb!=='cli')) we know this is to improve security but our client need constant update and we only keep limited routes in the routes file. for users like us we would like this to work like previous ci3 version. so can we get a config variable which allow us to turn this cli feature off, if we dont need to use it?
I'm not sure it is a bug or not.
But workaround is not to use $routes->add(), but use HTTP verb method: https://codeigniter4.github.io/CodeIgnit...http-verbs
According to the user guide:
Quote:Any route created by any of the HTTP-verb-based route methods will also be inaccessible from the CLI, but routes created by the add() method will still be available from the command line: This is the explanation for defined routes, but $routes->add() accepts all kinds of requests including CLI. So it is too restrictive that adding $routes->add() prevents access to the controller with auto routing legacy.
I sent a PR to fix this bug: https://github.com/codeigniter4/CodeIgniter4/pull/7690
The bug was fixed in v4.3.7.
|
Welcome Guest, Not a member yet? Register Sign In |