Drupal Sandbox Project: KMVC

As I always, I took my time to write another blog post. Again this one actually includes codes (but not here). I have started using Drupal for a project to a client. I was willing to work on Drupal for a while, but I never had the chance to look for it deeply or develop for it. Now I’m in with a sandbox module: Kmvc!

Some terrible things happened in my life last week (three days ago actually) and I needed to focus my attention to something else. I had started to write this module for our client, but later we thought it won’t be really useful to use it, so we dropped the idea (well you can see that I was against dropping it). So this idea morphed into a sandbox module for Drupal. KMVC is a micro MVC module for Drupal. Inspired by Zend Framework.

All you have to do is to call the bootstrap’s bootstrap function with some parameters and you are good to go. You don’t need to register menus, they are handled by the module. You create the controller and it’s actions and url registering is done automatically. If you are using Drupal check it out, on the project home page: http://drupal.org/sandbox/radalin/1434684

Before writing it I have looked for possible MVC modules, which I can use (Prometheus), however I don’t know why but I was not able run them. I didn’t try harder to make it working because I haven’t liked it anyway (the approach to the MVC). But it helped me to figure out how to do some things, I won’t deny that. It’s pretty subjective, so there is no need to discuss it, I’m sure someone else won’t like my interpretation of MVC which looks like Zend Framework a little bit too much.

What I wanted to do with this module was to abstract developers (mostly new) from Drupal’s internal modules and create an MVC style architectural style for developers who will developer their own module without thinking a lot about about registering routes etc. Another idea was to ease developing controllers that gave a JSON output instead of an HTML one. Now if you set it that way, a controller can return either an HTML or a JSON. There are also some minor implementation details for the _escaped_fragment_ handling too, but they are just a little bit experimental but they seem to work. My thoughts and need was, a little bit different from Prometheus so I created a new module. Some competition is always good (well as I’m a sandbox project, there is currently no competition but you get my meaning :)

I think that the best way to learn something is a hands-on experience, and it can turn out something pretty good or nothing at all. As someone who is generally using free software, I also want to contribute to it. These kind of blog posts helps the passing of knowledge, This drupal module, I hope it’s liked by others too, can be a good start for better contributing to the free (and open source) software.

The interesting part about this post it does not contain any code examples, they are all committed to the Drupal’s git repository: http://drupalcode.org/sandbox/radalin/1434684.git

There are still some things to be done. Tests are required, the multiple app issue should be handled better, some better documentation and a more complex sample is a must I suppose but it’s currently not horrible. Once these things are solved in my head I will apply as a full project (I’m actually looking forward for this part:). Some better integration with core drupal rendering methods might be good (or some basic wrappers but that might be pointless as well).

Feel free to discus (or create issues on the module page) this module on the project home page or here too. I will try to keep improving it in my free time and keep it as bug free and easy to develop as possible. It’s currently maintained only by me and currently I don’t have any plans to get more maintainers until I get a full project approval. Later, contributors and contributions and maintainers are welcome :)