There is already a sample application created by the Phalcon team that uses the Micro class, but I found it to be a little more specific than I would like. It uses things like the Volt template engine, models, Database connections, and some other glossed over Bootstrapping.
My example application contains very little. It has enough to get you started creating a simple JSON-based application, or just serving a static site with a few cached views.
Basic page example
Just shows a simple GET route and serves a single view.
Partial views (
Simple view engine)
The templates use partials for the header and footer of the site.
URL with params
You can pass parameters into the URL, and they will be rendered on the page.
An example of how to return JSON via a POST request. There is also a comment that tells you the jQuery test function to try.
This shows how you can serve a cached view, with an expiry. Good for those complicated pages that need to be refreshed every other day.
This one is really simple. It just shows how you can redirect one URL request to another.
I also included a simple grunt task that uses
livereload. This will refresh the browser when view files, or the
app.php file, changes.
You can find the repositry on Github. I will be updating and tweaking this project as I move along. It may become more feature-rich in the next few months. I would like to build a nice solid base for myself when using the Micro app.
There may be some need to add in some simple search examples, models, forms, validation, or even Database connections. But we will see if that is where it moved organically.