Now in Eggmatters:
The Poor Man's Framework
Overview of features and origin of the PMF
The PMF originated as a one-note kludge to get content onto my original site. After many iterations, The PMF is no longer a GET parameter RPC but a full RESTful Framework in its own right. The spirit of the PMF is to keep things as light-weight as possible. The PMF, ideally, should provide options — not rules.
That's the ideal. The reality, I've found is that the complexity of web application framework can grow quickly. This one is a constant battle between options and rules. Please feel free to download and review. Post issues with bugs suggestions and thoughts. Good luck!
Aside from being yet another RESTful framework (YARF), this project is more intended as a tutorial to expose different design patterns. As such, I intend to break the PMF down to individual steps that can be taken and modified. I've taken ideas (the good parts) from Symfony and Rails and incorporated them into this project.
I don't expect rapid industry adoption of this but, I want to develop it with that in mind.
While developing this project, I had a few insights for developing some newer, out-of-the-box features that either revamp existing ideas, or are things that have never been done. Following are some of these features.
- Declarative Routing I've done away (for the most part) with routing tables. A RESTful web request contains all of the resources required to discover the code needed to resolve a request. Dynamic routing parses incoming requests and decides which controller and method to call. There's a few conventions of course, but it does provide a great deal of flexibility. I will tackle this early on in the upcoming PMF lessons.
- Data source abstraction People are finally catching on. More often than not, I'm facilitating communications between an API and a persitence layer -- typically a database. REST defines 4 things I can do with both: Write, Read, Update or Destroy. Rather than go outside the bounds of a framework to connect to mulitple data sources, I simply wrote interfaces for whatever data connections you may have. Additionally, I've provided a normalizer interface so you can transform your data to model objects. The conventions? One connector type per model. Implement the interface. That's it.
- Cache abstraction Just like with data source abstraction, I've done the same for caching. Rather than shoehorn one type of server cache, I simply provide a mechanism for allowing your own mechanism, be it Redis, Memcache or something of your own devising. Once again, just implement the interface.
- Low-Key MySQL ORM with a twist The only reason I built an ORM in the first place is that I though it would be fun. This one came from a task where I had to write a SQL query against the information schema to capture all of the relationships between data. I naturally figured that an ORM could certainly benefit from that information. There you have it. You don't have to define how your data should relate, the PMF figures it out for you. So far, it captures one-to-one, one-to-many and many-to-many relationships. Outer Joins, Unions and other aggregates aren't captured. The syntax is fairly intuitive but is also limited. You can query a database. I trust you. Raw SQL is welcome here (just don't forget your bind parameters!)
And Furthermore . . .
I'm going to pick this up just like I did with the old site. I'm going to write tutorial articles as if you're developing this from scratch. Stay tuned. I promise to keep up.