So you want to create a web framework?

I have started to create my own PHP framework, mainly because I will know what's going on with the code and secondly because it should not take that much longer than learning a framework that might be obsolete in a year or so anyway. This series of post will be about how to create your own framework regardless of language, PHP, Ruby, Java, Python, C#, VB, Perl, Etc.

If you are writing your own framework you will need to account for these things:

  1. Language - The language you want to use. Pick one, I have found dynamic languages the most flexible to work with, but it does not really matter.
  2. IDE - The IDE you want to use is also very important. You will spend most of your time working with this tool, so pick one that's flexible, extensible, and you like.
  3. Versioning - Here the choice is something you can version your software with. I prefer CVS (Concurrent Versioning System) or SVN (SubVersion).
  4. MVC or Classic – I have never been a fan of full blown MVC frameworks, usually they rely too much on configuration and don't really save you much time (ala Struts), but if you are comfortable with MVC or Classic pick one and that will decide how you will structure most your framework.
  5. ORM / Data Abstraction – You will have a database, or some data store, this will map your data store to classes or functions making it easier to work with.
  6. Error Control – Your error control should work with all other aspects of your framework, I will call this an infrastructure component.
  7. Logging - While the web server provides some logging, and analytic packages exist, debugging and identifying problems when your applications breaks, the inclusion of a logging component makes fixing it much faster.
  8. Security (Authentication / Authorization) – Unless you have a static site, you will have users that need to be authenticated and authorized to do certain things with the data behind your site.
  9. Caching – Sometimes to improve the performance of your site, you may need to implement your own caching mechanism rather than relying on your language, web server, or a client's browser.
  10. Batch - If you have CRON, or Batch jobs for your application you will need to create a batch framework to interact with your data and/or the business logic of your application.
  11. Configuration - The more complicated an application becomes, the more likely you will want to extract all your hard coded strings to configuration files. While I don't recommend putting everything in a configuration file (a.k.a. J2EE) some configuration is handy.
  12. Mail / Distribution – Communication with systems and people whether via email gateway, phone, fax, or printing might be required and need to be coupled with your business logic, batch, or any of the other sub-systems of your application.
  13. Modules & Extensibility - Your framework should provide a way for people to extend it without impact on it's major sub-systems.
  14. Templating & Widgets & Skinning – If your application is reused by over and over or if used by others (anti-pattern of this blog) you might want to give the it the ability to apply themes or skins to it as well as custom site templates (similar to WordPress).
  15. Documentation - Well if it's just you, using your framework might not need any documentation, however if you build it move on to something else, then come back to your app after a few months or years (if it's good enough) having a documentation generator from code will be really nice.
  16. Testing - Unit, Integration, Regression test are all parts of building a stable robust application, but automating the process is even better.
  17. AJAX (Asynchronous JavaScript And XML) – A framework today has to include this buzzword. I suppose I could have included it with widgets above, however I will talk about this one in a separate post.

That's it for this post, in the next 17 or so post I will talk about each aspect of creating a framework. Stay Tuned…