I follow the tutorial 3 and add di for models folder
This is my index.php (assume my project folder is api) `` <?php
// Use Loader() to autoload our model $loader = new \Phalcon\Loader ();
$loader->registerDirs ( array ( DIR . '/models/' ) )->register ();
$di = new \Phalcon\DI\FactoryDefault ();
// Set up the database service $di->set ( 'db', function () { return new \Phalcon\Db\Adapter\Pdo\Mysql ( array ( "host" => "localhost", "username" => "root", "password" => "root", "dbname" => "test" ) ); } );
// Create and bind the DI to the application $app = new \Phalcon\Mvc\Micro ( $di );
// This is the start route $app->get ( '/', function () { echo "<h1>Welcome!</h1>"; } );
$app->get ( '/say/welcome/{name}', function ($name) { echo "<h1>Welcome $name!</h1>"; } );
$app->post ( '/test', function () { echo "Test post route"; } );
$app->notFound ( function () use($app) { $app->response->setStatusCode ( 404, "Not Found" )->sendHeaders (); echo 'This is crazy, but this page was not found!'; } );
$app->handle (); ``
When I run localhost/api/test, it show "This is crazy, but this page was not found!" in the notFound handler. GET route is fine, but POST route is error. Why is that? Thank you!