Routes going to somewhere I didn't set |
So, I recently facing an issue where I had a code:
PHP Code: $routes->add('operator/edit/(:segment)', 'Admin/Operator::edit/$1'); That code means to using controller Operator, right? But instead, I got directed to the controller Admin (The main controller) instead the Operator controller (screenshot). But, I'm a bit confused when I change the routes to: PHP Code: $routes->add('admin/operator/edit/(:segment)', 'Admin/Operator::edit/$1'); It suddenly work properly. Showing the views instead the error just like the screenshot above. Here is the preview (screenshot) when it's work properly. And by the way, I was using PHP Code: $routes->group('admin', function ($routes) { So the 2 routes above was inside the group. Here is the code for controller Operator and the views: https://srcb.in/NrGmkGXZ3T I don't know if that code and my explanation was enough but... Just let me know if you need more code or more my explanation to help me out, thanks!
Have you try Assigning Namespace?
https://codeigniter.com/user_guide/incom...-namespace (09-04-2024, 08:34 AM)Renta Ardhana Wrote: Have you try Assigning Namespace? Just great, now I got this even before I could go to the edit page... Well my full routes code are like this: PHP Code: $routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
Check your routes with the `spark routes` command.
See https://codeigniter.com/user_guide/incom...ark-routes
If you got 404 error, check your route definitions and the error messages on your screen carefully.
CI4 works as you configured, not as you want if you configure incorrectly. |
Welcome Guest, Not a member yet? Register Sign In |