Routing to a module adds App\Controllers to the route - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Routing to a module adds App\Controllers to the route (/showthread.php?tid=88093) |
Routing to a module adds App\Controllers to the route - andrew0378 - 07-19-2023 I need a little help to get a module to load correctly. My problem is that the handler generated for my defined route seems to prefix App\Controllers to the route in the module folder My Directory Structure is as follows: Code: ├── app \app\Config\Autoload.php PHP Code: <?php \app\Config\Routes.php PHP Code: <?php \modules\admin\Config\Routes.php PHP Code: <?php \modules\admin\Controllers\User.php PHP Code: <?php In the CI4 debug toolbar from http://localhost:8080/ (and http://localhost:8080/reachability): Code: MATCHED ROUTE From http://localhost:8080/admin I only get a 404 error: Controller or its method is not found: \App\Controllers\Modules\admin\Controllers\User::validate I do not get a CI4 debug toolbar icon on this url. I suspect it is something I don't understand about namespaces. I am new to CI. Thank you for any assistance RE: Routing to a module adds App\Controllers to the route - InsiteFX - 07-19-2023 PHP Code: 'Modules\admin' => ROOTPATH . 'modules\admin', RE: Routing to a module adds App\Controllers to the route - kenjis - 07-20-2023 Read https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#controller-s-namespace RE: Routing to a module adds App\Controllers to the route - andrew0378 - 07-24-2023 Apologies for the late reply. Only getting to this now. Thanks, the two answers combined to give me success. |