Hey Guys,
I'm currently rewriting my whole Project from scratch and want to organize my Controllers, Models, Plugins etc. with Namespaces.
So everything has a namespace like Test\Blubb\Controllers or Test\Blubb\Model or Test\Bla\Controllers
<?php
namespace Test\Blubb\Controllers;
class IndexController extends ControllerBase{
public function indexAction {
}
}
Added a Router with right namespaces for my diffrent routes and registered within DI. Also my namespaces are loaded with correct path with the Loader.
$router = $di->getRouter();
$router->add('/:controller', [
'namespace' => $config->namespaces->controllers,
'controller' => 1
]);
$router->add('/:controller/:action', [
'namespace' => $config->namespaces->controllers,
'controller' => 1,
'action' => 2
]);
$router->add('/:controller/:action/:params', [
'namespace' => $config->namespaces->controllers,
'controller' => 1,
'action' => 2,
'params' => 3
]);
$router->handle();
$loader->registerNamespaces(
[
$config->namespaces->controllers => '../controllers/',
$config->namespaces->models => '../models/',
$config->namespaces->plugins => '../library/plugins/',
$config->namespaces->components => '../library/components/',
])->register();
Now when i try to access the page I get this error:
Test\Blubb\Controllers\IndexController handler class cannot be loaded
0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('Test\Blubb\Contr...', 2)
1 [internal function]: Phalcon\Dispatcher->_dispatch()
2 [internal function]: Phalcon\Dispatcher->dispatch()
3 ....../public/index.php(42): Phalcon\Mvc\Application->handle()
4 {main}
It uses the correct namespace but cant find my Controller. Double checked my spelling for mistakes and searched through the net, no solutions that i found worked :/
Someone got an idea what might be the problem?