I don’t think there’s a day that goes by that I don’t see someone just coming into the world of PHP, eyes bright with promise and hope, ready to tackle just about anything that comes their way. Of course, reality sinks in and, unless they’re already pretty well versed with programming and the thought processes that go on behind it, they might take one look at PHP and run screaming. Of course, there are much worse kinds of languages (some that have functions that wouldn’t even make sense to someone who wasn’t “on the inside”). Thankfull, PHP is a low-entry language – people can come in, not have much programming experience at all, and, with some help from tutorials and the manual, make some simple little PHP scripts to do some smaller jobs.
Some people stop there – they’re happy that they learned something, and what they wrote – even if it took them four days of twenty hours each to finish the five lines of code, they’re happy and pround of it. Of course, it won’t take long before they look at it, realize that there has to be something better and set out on a course to follow in the footsteps of many before them – to really learn the language.
So, you ask (being one of those with the resolve to go on) – how can I learn all there is to know about PHP? What do all of these funny things mean in these “class” files? Why can’t I just stick with procedural code all my life?
Well, lets take a step back and start from the beginning – programming itself. Ever since computers came on the scene, there have always been programmers (duh). In the early days, they were the pioneers of the technology world, forging ahead to make ever bigger and better pieces of software for the world to use. They mucked about in their digital playground, building the physical form of the logic that sat in their heads, making real what was just an idea. Unfortunately, with the general state of the web these days, this pioneering spirit seems to have gotten a bit lost in the details. Sure, there are those out there that are forging the way into the new land of “Web 2.0″, but on the whole, things seem to have plateaued a bit. So, how can you, a budding programmer take part in all of this? Well, the real question you should be asking yourself isn’t so much “what big thing can I do to make a difference?” but “how can I make what I can do the best it can be?”
So much of the programming that I see is more of a hack job than anything else. Yes, I’m as guilty as the next developer out there of doing this, but there just comes a certain satisfaction with creating something that you just want to show off to another developer and see their jaw drop, just a little, when they figure it all out. Programming is an art, it’s an extension of you, who you are and how you work. It’s never static, and acts as a fluid whole always changing shape but never breaking form.
So, enough of that – you want to get down to the real meat of the subject – how can you, a developer somewhat skilled in the ways of PHP, learn as much as you can about the language in the shortest amount of time.
The easy answer? A project
The harder answer? There is no easy way.
PHP throws people off by being such an easy language to get into. They look at it, they understand what the functions do and their names, and they know how to get things to cooperate when the time comes. However, making a quick script here and there is nice, but it’s not going pull you into the language like you’d need. For that, you really need a project to work on.
No matter what project you choose, however, you need to always plan before you start writing. Lots of projects show evidence of poor planning on the part of the developers, and it shows. Code is hard to update and difficult to add new features to, and at some point, the developers would rather just scrap the whole thing than have to work with it one more minute. So, the monal of the story? Plan, plan, plan. Take your project, step back, and look at what it really needs to accomplish. Break it into chunks, take it apart in your head. One good method for breaking it out is to think of it in steps. Say your application is a simple content manager – all you really want to do is put information into a database and pull it back out. Nice and easy, right? Well, take that simple project and look at it in bits – something to display the data, something to put the data into the database/text file, and something to handle both of those. So, three parts – three scripts. You can create one page thats goal is to simply pull the information out, one page that uses something like a form to put the information in, and another single shared file that helps you with parts of both – a library of sorts that you can call functions from.
Now, if that sounds a bit overwhelming, then break it down even more. The real key here is to keep breaking down the tasks that you have ahead of you until you know what you’re doing. Don’t try to tackle a database abstraction layer on your first day. Instead, take a look at some of the database functionality – learn how to read and write to it, learn some of the basics of SQL. PHP makes it very simple to interact with it (MySQL or the like) quite seamlessly.
So, here’s a handy little list of suggestions to follow to help you get more out of your PHP experience (some that have been mentioned, some that haven’t):
- Break it down, now! – don’t focus on the project as a whole except at the beginning. Break it down into chunks that you can do and work towards that. Then, as things progress, you’ll find the smaller steps easier and the larger ones “just happening”
- The manual is your best friend: I see too many questions (like on ##php on freenode) that could have been answered by a quick look in the manual. If you’ve been working with PHP thus far and haven’t see the manual, head on over to php.net/manual and discover the joy…
- Remember that programming is more than just writing code: when you create an application, think of it as that – a creation. One that needs to be thought out, planned, and cared for just like any other thing. The less you take care of it, the more it’ll come back to haunt you in the future.
- Tutorials and all are nice, but you have to strike out sometime: get your feet wet with some examples and tutorials, but don’t expect there to be a tutorial for everything out there. Sometimes, you just have to take an idea, forge ahead, and make your own trail…
Well, hopefully this has been useful to someone out there. I know there wasn’t any code involved, but I didn’t want to get into that. I wanted to talk more about what it is to program and how that can apply to PHP. As always, if you have comments/suggestions/flames/death threats, feel free to leave them below in the comments…