We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon REST API problem

I have a project written in phalcon with api folder: root/api/index.php , index.php file content: <?php

$app = new \Phalcon\Mvc\Micro(); $request = new \Phalcon\Http\Request();

$app->get('/test',function(){ echo "Hello from API !"; });

/**

  • 404 Not Found Action */ $app->notFound(function () use ($app) { $app->response->setStatusCode(404, "Not Found")->sendHeaders(); echo '404 Not Found !'; });

$app->handle(); ?>

My domain is beta.ketqua.vn. API base url is: beta.ketqua.vn/api. When i try to test API using curl command line with this code: curl -i -X GET https://beta.ketqua.vn/api/test i retrieve "404 Not Found" from $app->notFound. In localhost in work very fine :(. How to fix that ???

after:

$app = new \Phalcon\Mvc\Micro(); 

insert:

$app->getRouter()->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

Thanks you very much Pavel Makarenko !

Thank you Pavel Makarenko!