<?php
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
__DIR__ . '/models/'
))->register();
$di = new \Phalcon\DI\FactoryDefault();
$di->set('db', function(){
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'test',
'charset' => 'utf8',
));
});
$app = new \Phalcon\Mvc\Micro($di);
$app->get('/api/product', function() use ($app) {
$phql = "SELECT * FROM product";
$products = $app->modelsManager->executeQuery($phql);
$d = array();
foreach ($products as $product) {
$d[] = array(
'id' => $product->id,
'data' => $product->data,
);
}
echo json_encode($d);
});
$app->handle();
The error is:
( ! ) Fatal error: Uncaught exception 'Phalcon\Mvc\Micro\Exception' with message 'The Not-Found handler is not callable or is not defined' in C:\wamp\www\api\index.php on line 34
( ! ) Phalcon\Mvc\Micro\Exception: The Not-Found handler is not callable or is not defined in C:\wamp\www\api\index.php on line 34
Call Stack
# Time Memory Function Location
1 0.0013 259720 {main}( ) ..\index.php:0
2 0.0020 275472 handle ( ) ..\index.php:34
How can you fix this error?