When Rasmus Lerdorf announced Personal Home Page Tools 1.0 in June 1995, I doubt that he had enterprise software development in mind. Fourteen years later, the CTO of Zend software, Zeev Suraski, shows me a slide. It has a large area shaded light blue, representing all the part-time or hobbyist users of PHP, and a thin strip of darker blue representing corporate PHP developers or ISVs (independent software vendors) offering PHP applications.
"Those two categories are growing significantly," says Suraski. "In 2006 we're talking about maybe 10% or less of the entire user base, whereas by the end of 2009 Gartner expects it to be about 35%. This changing demographics is a sign of maturity for PHP."
He would say that, of course, because that thin strip is Zend's potential customer base. The company sells a professional IDE for PHP, support services, and the just-released Zend Server which packages PHP along with commonly used companions such as MySQL. There is also an optimizer (technically an op-code cache), a Java connector, and the paid-for version has additional monitoring, debugging and caching components.
It is not just talk though: Zend is flourishing despite the recession - "the Q1 of 2009 has been our strongest quarter ever," says Suraski - and although PHP's enterprise market share is small compared to Java or .NET, it is growing.
What interests me is why this has happened. It is partly thanks to the merits of PHP, its speed and simplicity, and the fact that Java's libraries and to a lesser extent those in .NET are over-engineered for many tasks. More directly important though is that the community using PHP - the large area of non-paying users in Suraski's slide - has created a remarkable pool of resources on the Internet that is available to everyone, business users included. Non-commercial users are those most likely to share their knowledge, unfettered by concerns over business confidentiality or copyright.
I experienced this for myself recently, when I sat down to write a small PHP application. Every problem I encountered was quickly resolved with a Google search, or by looking at the discussion attached to entries in PHP's online documentation.
II don't mean to belittle the extent of online resources available to Java or .NET developers, but would argue that PHP has the edge here.
I also realise that it is no good just doing a search and adopting the first solution that seems to work. Developers need to understand what is being suggested and assess its quality, rather than optimistically pasting in the first block of code that seems to work. If PHP has a weakness, it is that the language does little to help developers write secure, maintainable applications, which may explain why there are so many vulnerable PHP applications out there.
So what about Zend Server? Note that this is not an application server in the WebSphere sense; it is primarily a PHP platform installer and support package, and as such not that different technically from what you can do with a Linux package manager or something like XAMPP.
I tried installing Zend Server on Windows Vista and bravely chose the IIS 7.0 integration rather than Apache. It actually worked smoothly and will be fine for developing PHP applications, though I would normally deploy to Linux, which I gather is a common scenario. That said, the work done by Zend and Microsoft makes PHP on Windows Server a reasonable option as well, and one that makes sense if you need to integrate with .NET, SQL Server or other Windows services.
The real winner here is PHP. Zend is making it business-friendly without damaging its open source ethos, and in doing so providing a great example of how free software can sidle its way into the enterprise.
Historically, the web development choice between the Microsoft platform and open source has been a fork in the road with many consequences. Choose Microsoft, and you generally use Visual Studio, Internet Information Server, ASP.NET, C# or Visual Basic, and SQL Server for the database manager. Choose open source, and you most likely target LAMP in one of its guises, the most common being Linux, Apache, MySQL and PHP, and work in Eclipse or almost anything other than Visual Studio.
Recently the boundaries have been blurring a little. Apache actually runs nicely on Windows, and I've used it happily to host a Subversion repository, while on the other side Microsoft has been making an effort to support PHP in IIS 7.0. But what about running ASP.NET on Linux, is that a silly idea?
I've been following the efforts of the Mono project in this area for some time, though it's been a while since I've tried it out. Mono was originally focused more on desktop than web applications, and I've used it mostly in that context. When laterooms.com tried Mono in early 2006 it quickly gave up, citing problems with Mono's Boehm garbage collector; see the developer's comments to my blog post at the time.
Still, that was three years ago. I had another look a couple of weeks ago, and I've been impressed. In particular, the ability to develop in Visual Studio and deploy to Linux is interesting. I'm working on a small project, and getting this working is remarkably simple. I used Visual Studio 2008, but set the project to target .NET Framework 2.0, as Mono lags behind Microsoft in implementing the latest .NET APIs, and using MySQL rather than SQL Server, since this is available on my Linux web server. Using MySQL with .NET is straightforward thanks to the official ADO.Net provider, which specifically supports Mono as well as Microsoft .NET.
On the web server, running Debian 5.0 Linux (Lenny), I installed the libapache2-mod-mono and mono-apache-server2 packages using Aptitude. Next, I configured Apache to use Mono on a particular web site, with a few lines of manual configuration, as explained here, and imported the MySQL database from the Windows development machine to the Linux web server.
Back in Visual Studio, I compiled the web site, uploaded it, and it worked first try. Performance is good as well.
I realise that a number of caveats apply. It's worth reading this page, the current Mono todo list, which notes some of the important areas where Mono is lacking and includes the comment:
Mono is known to be not as performant as the .NET Framework.
Note that Mono still uses the Boehm garbage collector, though an alternative is in development. Further, Mono does not implement the entire .NET Framework. Mono is a brave choice; Windows and IIS the sensible option for .NET applications.
It still seems to me significant that you can easily deploy to Linux and Apache using Mono. Not all applications are mission-critical, and not all applications need to scale as well as Laterooms.com. Mono has a number of attractions. First, it is open source, so in the event of problems you can always obtain and amend the source code. Second, running on Apache and Linux is a considerable saving in license costs. Third, you can get official developer support from Novell.
Why would you use C# and ASP.NET rather than PHP or Java? The main reason would be because you know and like the language, the platform, and/or the Visual Studio IDE. In an interesting report on the state of the computer book market, O'Reilly notes that C# is now the largest programming language for all book sales. Thanks to Mono, you can use C# but still deploy to an open source platform.
It also seems to me that Microsoft's official support for Moonlight, the Mono implementation of Silverlight, is important. Microsoft now needs Mono, in order to tick the cross-platform box and compete with Flash, giving more assurance to its long-term future.
Mono's growth over nearly a decade has been slow but steady. Perhaps now is the moment that it creeps into the mainstream.
Are you using Mono, for web or desktop development? I'd be interested in your comments.
It's hard not to love PHP: fast, powerful, and useful for anything from quick web scripts to major applications. The trouble is, PHP is just too forgiving for my taste. I've been working with PHP recently and occasionally made some silly errors (my excuse: it was late). I mostly work in other languages, so from time to time I would forget that in PHP variables all begin with a $ character. In other words, I wrote code like this:
$err = 0;
if (err)
{
print("<b>No match with this username and password. Please try again.</b>");
}
Unfortunately for me, the code ran fine. PHP sees err as an undefined constant which it assumes has a string value of 'err', so the if condition passes. For those used to strongly-typed languages such as C,Java or C#, this kind of error is unexpected, as in those languages the equivalent code will not even compile. Silent errors are particularly dangerous, since they are more likely to make it into production code with possibly calamitous consequences.
I guess the solution is not to make errors like that; but if you are like me, anything the tools can do to help catch errors is welcome. One possibility is to change the error_reporting value in php.ini. If you set it to a strict setting like this:
error_reporting = E_ALL | E_STRICT
then PHP will report likely problems in a manner that even a tired programmer will notice:

Check out the comments in php.ini for a description of the options. You would likely only use a strict setting like this in your development environment, not in production.
A snag with this approach is that many PHP libraries out there do not expect such a strict setting and will throw up all sorts of warnings. It wasn't a problem for me, as on this occasion all the code was mine.
As an aside, I've enjoyed working with PHP. I used to find that it almost encouraged spaghetti code, but the object-orientation introduced in PHP 5.0 has made it easier to structure applications in a way that I like. I've also started using the PHP Development Tools (PDT) in Eclipse. If you use this together with an instant PHP environment such as XAMPP, it is easy to set up a desktop for PHP development with luxuries like syntax highlighting, code-completion, and step-through debugging. Taking all these things together, I've found that most of my objections to using PHP no longer apply.