Controller in subfolder - 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: Controller in subfolder (/showthread.php?tid=73173) |
Controller in subfolder - GuilhermeBiz - 03-26-2019 Hello all, I'm studying how to separate my project so that my Controllers don't get too big, with many methods and parameters in each method, wich could cause a tremendous headache in future development. For doing so I wish to create subfolders inside the /app/Controller folder, and save my Controllers there, but I'm having trouble defining the Route for them, here is what I've tryied: $routes->add('configuracoes/callcenter', 'Configuracoes/Callcenter::index'); or $routes->add('configuracoes/callcenter', 'Configuracoes\Callcenter::index'); or $routes->add('configuracoes/callcenter', 'App\Controllers\Configuracoes\Callcenter::index'); But all I get is: "Controller or its method is not found: \App\Controllers\Configuracoes\Callcenter::index" My folder structure is just like this: App -Config -Controllers --Configuracao ---Callcenter.php etc... Any tips? RE: Controller in subfolder - GuilhermeBiz - 03-26-2019 As I've saw in other topics on the forum, just after making the post I figured out what I was missing... It was the Namespace from my Controller file, I was copying from the default one and only changing the Class name, but changing it to: <?php namespace App\Controllers\Configuracoes; The controller was loaded just fine and I resolved my issue. [/close] RE: Controller in subfolder - titounnes - 03-26-2019 (03-26-2019, 04:30 AM)GuilhermeBiz Wrote: Hello all, I'm studying how to separate my project so that my Controllers don't get too big, with many methods and parameters in each method, wich could cause a tremendous headache in future development. For doing so I wish to create subfolders inside the /app/Controller folder, and save my Controllers there, but I'm having trouble defining the Route for them, here is what I've tryied:try this $routes->add('configuracoes/callcenter', 'configuracoes\callcenter::index'); |