One of the things I hear from people and my friends is questions about the best way to work with PHP. They always want to know how to get started on a project, what software to use, how to plan it successfully, and so on. In this article I plan on revealing the “magical secrets” about how I do my PHP programming so quickly with so few bugs.
I’d bet a piece of paper and a common writing utensil could help you out here. The most important thing to think isn’t, “where should I start”, but “where do I want to start?” I always start with the graphic layout of a site before I do any coding. This why I know what my limits are when I’m trying to code something. I know what kind of output I can work with and simple things like that. Then I figure out what the main focus to the project itself is, and I go from there.
Usually it’s best to get the most important part working first so that you have something to show, and not to mention you can get input from other people on what they think of it, before you go putting a bunch of time into the things that aren’t as important. On most of my projects, I always start with the database connection first, then I move on from there, usually to the authentication, then the layout and interface. Finally I code any content management systems I may have, followed up by the smaller and more tedious parts; they usually include things like allowing the users to have an avatar, and things like that.
Doing it this way is usually the best way because if a project gets abandoned, you’ve probably now got something cool that you can add to your library of scripts to help you build your scary PHP empire later down the road.
I’ve also found that if you do in fact code the big parts first, you’ll see that you’ll spend less time going back to update finished code to work with the new things you have. And there’s less of a chance of the project being abandoned due to the lack of visual progress. Not to mention you get one of those really cool feelings of accomplishment half way through a project when you finish the important things.
Another reason I like to code the bigger more important parts first is because you’ll get stuck on something at one point, which will make you search out an answer to your problem. You’ll end up learning a lot of new things about PHP that you probably didn’t know, but you’ll remember them because they’re so cool that you’ll want to use some of the things you find in the smaller parts of the project for added functionality. I mean really useful things too, like the mysql_fetch_object() function. Do you know what that does? If you don’t, I bet you’ll say “WOW that’s so cool and useful” as soon as you look at the PHP documentation to find out what it is.