Hi guys,
I've been trying out Phalcon 3 and I've made dev env with https://phalcon-compose.readme.io/
But I keep geting this error message in app.
Every time this code:
echo (new Application($di))->handle()->getContent();
Produces this or similar error:
MyMapApp\Controllers\IndexController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('MyMapApp\\Contro...', 2)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 /project/public/index.php(19): Phalcon\Mvc\Application->handle()
#4 {main}
My loader looks like this:
$loader = new Loader();
$loader->registerNamespaces([
'MyMapApp\Models' => $config->application->modelsDir,
'MyMapApp\Controllers' => $config->application->controllersDir
])->register();
require_once BASE_PATH . '/vendor/autoload.php';
Router & dispatcher like this:
$di->set('dispatcher', function () {
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace('MyMapApp\\Controllers');
return $dispatcher;
});
$di->set('router', function () {
$router = new Phalcon\Mvc\Router();
$router->setDefaultController('index')->setDefaultAction('index');
$router->removeExtraSlashes(true);
$router->add('/homepage', ['controller' => 'Homepage', 'action' => 'index']);
$router->add('/login', ['controller' => 'Login', 'action' => 'index']);
return $router;
});
Does anyone have an idea what could have gone wrong so I get this error and how to fix it?
P.S.
Even if I create default IndexController that looks like this:
class IndexController extends Controller
{
public function indexAction()
{
return "<h1>Homepages!</h1>";
}
}
I also get similar error:
Homepages!"; } }MyMapApp\Controllers\IndexController handler class cannot be loaded
#0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('MyMapApp\\Contro...', 2)
#1 [internal function]: Phalcon\Dispatcher->_dispatch()
#2 [internal function]: Phalcon\Dispatcher->dispatch()
#3 /project/public/index.php(17): Phalcon\Mvc\Application->handle()
#4 {main}