I'm trying to figure out the best way to make access to most of my backend data available through a REST api so that I can take advantage of dynamic queries on the client side. However, I also want to serve up normal html from the same site. Being a noob at phalcon and web development in general, I'm not quite sure what the proper way is to organize these two services.
In order to achieve this, first I tried to have a single controller which would handle both. It seemed that there would be conflict with some of the method naming ( i.e. deleteAction() would mean two different things dependent on if it was a DELETE request or a GET with an action of delete ) and I wasn't sure how I would be able to determine which was the proper scenario. Then I started down the path of having an 'api' folder under /app/controllers/ -> /app/controllers/api where all of my REST controllers will reside, which led to a routing issue which I have yet to figure out. So then I explored the module option, but then decided before I went too far to ask the forum on what the best practice is for this - as I'm pretty sure it is a common scenario.
With that said, how should I tackle this? 1) Split the web application into two modules - an API module and a typical html content module? 2) Peform special routing which knows that when the url starts with './api/:controller/...' it knows to look up the controller in the corresponding 'api' folder? 3) Have a single controller to serve up both? 4) None of the above
Thanks in advance.