Ruby on Rails (”Rails”) is a great development platform because it is specifically designed for rapid development, deployment, and maintenance of database-driven websites. But what if you are still using PHP and you are not ready or able to switch to Rails? Luckily, a lot of the concepts that are built into Rails are also good concepts to keep in mind when using PHP.
In this multi-part series, I will illustrate the use of some Rails principles in the PHP world.
Principle: Convention (default behavior that is expected)
Rails stresses conventions. An often-used Rails expression is “convention over configuration.” For example, Rails expects files to be named in certain ways and placed in certain directories. This keeps everything organized and clean. Are you sticking to any conventions with your PHP projects? You may find that taking some time to simply rename and organize your project files can do wonders for your productivity and ease in maintenance.
Consider for example, if you are developing a project to keep track of an automobile dealer’s inventory. Your users will need to see a list of available cars, maybe search by model or color, and then be able to click on a listing for more details, including the price and the vehicle identification number, and finally, they will need to edit or delete individual listings. Even if you are not that familiar with MVC programming, you will notice that your user will have 3 basic “views” of the inventory: (1) an overall listing of all cars, (2) a detail look at a single car listing and (3) a detail look at a single car listing that can be edited. The common aspect of all these “views” is cars, right? So, you may want to create a subdirectory called “cars” and within that directory name your scripts to handle the task of each of these: “list.php”, “detail.php” and “edit.php”.
Next, you will probably need to keep track of users for this system, including their names and passwords. As with the “cars” subdirectory, you might consider creating a “users” subdirectory with “list.php”, “detail.php” and “edit.php” to handle the tasks of working with the authorized users for the system.
Now, imagine the ease of using URL’s like “cars/list.php” or “users/list.php”. Likewise, imagine the simplicity of working with “cars/detail.php?VIN=AS1223827″ or “users/edit.php?name=Tom”.
It may seem simple, but a lot of PHP programmers do not create logical subdirectories based around the “objects” of their application. In our example, the objects were cars and users. When you work on your next PHP project, try and stick to some conventions for your project. That way, you may not only simplfy your development, but also ease your maintenance down the road when you’ve long forgotten all the details.
Next time, we’ll explore another aspect of Rails and how it can apply to PHP development.
![]() Bookmark on del.icio.us |




May 31st, 2010 at 5:31 pm
Yo Bro
A friend of mine just emailed me one of your articles from a while back. i read that one a few more.
L8er
June 1st, 2010 at 2:50 pm
Good Day
Excellent ideas here, have emailed my mum so expect a big reply!!
June 1st, 2010 at 2:50 pm
Greets
Excellent ideas here, have emailed my mum so expect a big reply!!
Whats yer opinion on paint?
June 9th, 2010 at 5:07 pm
meself found your site on Google Blogsearch and meself and read a few of your other posts.
Ciao
June 9th, 2010 at 6:16 pm
I must say this is a really cool article I enjoyed reading it keep da good work
Me love dha site template
Cu Later
June 9th, 2010 at 6:16 pm
Hi
That was INTENSE. i really want to read this book now!
June 9th, 2010 at 6:16 pm
Every one on internet searches for good content. Its very unfortunate with most of the websites published posts that are boring and out of context articles, just to show that new material is being published. Contrary to that immoral practice, this article is a good-written article.
If you want to exchange links let me know.
June 12th, 2010 at 2:55 am
Moin
Hey I came across your page by luck on ask while hunting for something totally irrelevant but I am very glad that I did, You have just captured yourself another subscriber.
you have a website aswell.
June 12th, 2010 at 4:17 am
Greets
Many thanks regarding your page.I genuinely love your web page.Its really informative.Nevertheless I truly want you to post how you put social bookmarking below your post.i like it since its a really clean cool mod.
Goodbye
June 14th, 2010 at 2:56 pm
Realy cool stuff, My bro managed to make my blog
Yours Sincerly
June 28th, 2010 at 2:28 pm
Good Day
Your article has added very nice value to your site. myself say this because to me personally myself find it very nice. Maybe to some one else its not but to me you did very nice. thank you very much for da info.
July 11th, 2010 at 7:08 am
Hi! Our organization are searching for upcoming freelance writers, would certainly you be curious? Doing this probably won’t prepare you wealthy except there is an essential payment and if you fully have a passion for freelance writing then this one gig is for you.
July 13th, 2010 at 7:57 am
Hiya! Your message support me personally acquire an incredible grade and I thank you for that. Do you provide several type of donation box where I may well send donation in PayPal?
July 16th, 2010 at 5:15 pm
Hows It Going
Good stuff i will try & get back to you gracias
Please email me if you are interested
L8er
July 21st, 2010 at 2:46 pm
Good stuff, It might just work, although it seems easier when you have a plan.
July 21st, 2010 at 2:46 pm
Well this kind of information is really worth searching for, really cool information for readers and a value for you as will definitely show teh quality of teh writer. Its really cool to have these kinds of articles around to keep teh information flow steady. Helping those who really can make things right in teh future, really cool work!
July 21st, 2010 at 2:46 pm
Hello There
Have you considered writing professionally? Like a periodical or something?
July 21st, 2010 at 2:46 pm
Greetings
Hey My bro came across your page by luck on ask while hunting for something totally irrelevant but My bro am very glad that My bro did, You have just captured yourself another subscriber.
I love the site template
July 21st, 2010 at 2:46 pm
Hows It Going
Realy cool stuff, my homie managed to make my blog
July 24th, 2010 at 9:11 pm
you finally decided to write a comment on your blog. you just wanted to say good job. you really had great fun reading your posts.
you discovered your homepage by coincidence.
July 25th, 2010 at 9:07 pm
Hows It Going
Me look forward to reading more from you. Have a very good week.
July 28th, 2010 at 9:06 pm
Hiya! Our organization are browsing for potential authors, would you be curious? It wont help you way too rich sadly there is an appealing comp and if you highly love writing then doing this gig is for you.