Freelance PHP consultant Lorna Jane Mitchell explains why PHP’s bad reputation is unwarranted, explodes some popular myths and suggests some excellent resources along the way
PHP has the reputation of being the poor cousin of scripting languages, due to outdated language features and plenty of poor quality code written using it. I use PHP as my main programming language and it’s seen waves of change over the last five years; it’s so much more than a language for script kiddies and hobbyist hackers. There are some ‘truths’ about the language that aren’t true these days, so I’d like to bring you a little update.
“It’s not as good as Rails”
“PHP is not bad,” some say, “but it’s not Rails.” Well, no, because one is a language and one is a framework, so the comparison is irrelevant. PHP doesn’t have one ‘Rails’, it has thousands of frameworks, which means you can pick the right tool for the job. If you need a structured, full-stack framework, then try Zend Framework. For a components library, I suggest Zeta Components is worth your attention. And if you just need some lightweight scaffolding then check out CodeIgniter or its newer community fork Kohana.
“It’s an incomplete object model”
In PHP4, this statement was actually true: object support was kind of hacked on to arrays, with rather interesting results. However PHP5 was released in 2004 and PHP4 hasn’t been supported for a few years now, so it’s an urban myth at this point in time. PHP5 has a true object model with the things one would expect to see: access modifiers, interfaces and so on. It only has single inheritance, which can be a surprise for those from disciplines with multiple inheritance; but in general, if you’re a software engineer, you can work with PHP without tearing your hair out.
“There’s a lack of best practice”
This was probably true at one time, and certainly there are a lot of day-job PHP-ers out there just turning out more of the same code. But at the conferences and on the PHP news sites, there’s a lot of content about improving quality of tools and process. Unit testing is commonplace, helped by the awesome xUnit tool, PHPUnit. Source control is a requirement for pretty much all projects, but most will also include deployment processes – contrary to the stereotype, I don’t remember the last time I FTP’d a file for any reason. While Subversion is still prevalent, the open source projects I see in the PHP sphere are increasingly moving over to Git and other DCVS solutions – and where the open source tools go, the rest of the industry is likely to follow.
Combine all of this with PHing to automate the various steps for deployment and phpUnderControl or Hudson for continuous integration, and PHP projects are looking more and more like a serious software project should.
The package deal
Every community around a technology, whether platform, language, framework or anything else, has its own character and values. I find the PHP community very open source in its attitude. There is no particular leadership, although you have to earn the karma to commit to the language itself. The best textbook for PHP is the manual at php.net, written and maintained by the community itself. Because of its open nature, almost all of the best resources are freely available. There are also some great sites that bring these resources together. If that sounds interesting then check out Planet PHP, a syndication of some of the top PHP blogs, or PHPDeveloper, a site that rounds up the best PHP posts across the net.
The sheer ubiquity of PHP, available often by default or very easily on every platform, means it’s always at hand to solve a problem. There are some fantastic open source products built with PHP that will save you time and headaches, and yes, there are plenty of truly awful ones as well, because this is an open community and anything goes!
The community itself is relaxed and friendly, and at its core, it’s a meritocracy – so join in, you may be surprised at what you find.
This article originally appeared in issue 214 of .net magazine - the world's best-selling magazine for web designers and developers.