• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller in subfolder

#1
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?
Reply

#2
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]
Reply

#3
(03-26-2019, 05: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:

$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?
try this
$routes->add('configuracoes/callcenter', 'configuracoes\callcenter::index');
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.