Friday, November 14, 2008

A different step

Its been about a week since I have been helping the guys out with some PHP. I thought to do so so that I could also get a hang of the language and the usages. But I'll say it came natural to me. The project was one which was partly developed and was currently being extended. The code written was awesome. Complex but Awesome.

The previous time I did PHP was in the college and I feel pity at what I did. No MVC at all. Just write all the crap in one php and render it. Pretty Lame and Bad. The code here was carefully split into Model-View-Controller and all the URL rewrites were also written. WAMP is the server and all the rewrites written into the .htaccess file. PEAR classes were used for database interaction and the Models were created using written code which generates the php.ini file. The view was programmed to render after the controller had done its job of initializing and assigning variables.

The stuff that attracted me was the Cookie usage. The stuff like filtering results and sorting was stored in Cookies with respect to each page. This had the advantage (disadvantage to some) that the page seems to maintain its state through out the life of the application (so long as the cookie is not deleted). Classes were written for each Cookie kind (say a cookie for search had a class Search) and initializers were set so that the value could be accessed via PHP. Great Idea !!!

I would probably do something of this kind if I get a chance in Ruby On Rails. Let me see if I could get something of this kind !!!

No comments: