Code that takes care of database connection is often put into services container. The basic idea is to bootstrap your application in that manner.
I'm just about to finish development of one Micro app which primary task is to handle RESTful queries. I can publish it on github when finished. It might not be best suited for beginners, since it extends Phalcon with various components to glue everything together, i.e. handlers are defined with a dedicated service component, and business logic is implemented in controllers with custom models / ORM.
In short, if you follow the tutorial on Phalcon site, your structure should looks like this:
- my-rest-api/
- models/Robots.php
- index.php
Basically, everything goes into index.php. Only part which defines Model goes into Robots.php.