RSS

AM Framework

Written by: JT in Web Technology

At the beginning of one of our client projects, we were faced with the question of which framework to use. While we had looked at a few in the past (CodeIgniter, Kohana, etc…), we still weren’t quite set on a particular one and since the project didn’t seem overly complex at the time, we thought why not build our own? Well this is its story.

The AM Framework started with a list of requirements:  MVC, easy to use AJAX, and ActiveRecord based models, all of which were to be built using PHP. To create the MVC structure, we made some basic load functions for each particular aspect. Some (i.e. the controllers) were automatically called, while others (the views and models) were called where needed inside of the controllers. This method worked well allowing us to reuse pieces throughout while keeping them separate.

When it came to AJAX, we had to pick a library. We chose jQuery because of some experience with it plus the plugins available made some of the more interactive features easier to attain. We built a simplifier function to wrap jQuery’s AJAX call, which would automatically parse the basics of the response from our system, then hand it off. This turned out to work well for some, but not all, cases. As for the response itself, the application was set up with a special class that would take the system response and output it in a specific view. The communication worked well with a lot of the success/failure responses being automatically handled.

The ActiveRecord implementation we used was basic and we only added what we needed. We set up the models to be autoloaded when called and all of them had a find function which took in some parameters and returned a single or set of objects. From that object, we could read or manipulate the data (and its relationships) and save it back into the database.

These main pieces worked well together and the development was much easier by having many of the little things taken care of for us. From the experience, you realize a lot about the variety of frameworks and their importance; although, I think with the opensource frameworks already available, it’s tough to come up with a good reason to build your own.

 

  • Share/Bookmark

Leave a Reply