I am having a bit of difficulty understanding how I can implement an API in a separate directory using an Application
type object instead of an Micro
.
Currently when I try to implement:
$application->get('/api/robots', function () {
});
within my index.php
inside public, where I create:
$application = new Application($di);
echo $application->handle()->getContent();
It always treats them as view controllers
and ask for a controller
. I tried following the docs for creating a simple RESTful API
and I ended up creating a separate folder called api
where the micro index.php
(follows the exact layout of the api micro application in the tutorial) lives, but at the end of the day I keep getting the ApiController not found
.
I am a bit stumped and any clarification/simplification would be very helpful!
Here is the tutorial: https://docs.phalconphp.com/en/latest/reference/tutorial-rest.html