Hi! I have an issue with micro app. My app is very simple:
index.php
define('BASE_PATH', dirname(__DIR__));
define('APP_PATH', BASE_PATH . '/app');
$loader = new \Phalcon\Loader();
$loader->registerDirs([
APP_PATH . '/classes'
]);
$loader->register();
$app = new \Phalcon\Mvc\Micro();
$app->notFound(function() use ($app) {
$app->response->setStatusCode(404, 'Not Found')->send();
});
$app->error(function($e) {
echo 'error';
return false;
});
$col = new \Phalcon\Mvc\Micro\Collection();
$col->setHandler('IndexClass', true);
$col->get('/', 'index');
$app->mount($col);
$app->handle();
IndexClass.php
class IndexClass
{
public function index() {
die('index');
}
}
The problem is the following: when I open home page, I see text 'index' as it's expected. But when I open something like '/lalala' (that is not described in routes) I see 500 error. I'd like to handle it and show 404 page instead. My error handler is not working in this case. What am I missing? Thank you.