Earlier today I saw the announcement that PHP5.4 will have a built-in web server . I mentioned on twitter that I wasn’t too happy about the server being added. In the discussion that followed, I feel like I wasn’t able to properly convey my thoughts through tweets. I figured I might be able to better explain myself in a post.
I have mixed feelings about the built-in web server to be honest. Having a low effort web server is great for lowering the barrier to entry when building things with PHP. I can also appreciate the instantaneous feedback you get from a simple command line server, and not needing to fiddle with Apache or other more complex web servers. All of these things seem really great in isolation, and when you ignore some of the problems that it creates.
I can think of a few problems that the new command line server creates. First, while its intended for quick and dirty development, it will invariably end up being used as a production server somewhere. PHP already has a spotty track record with providing features meant to be helpful, but later become painful. I’m thinking of things like magic quotes and register globals. All of these features were at some level intended to make development easier. Instead they have become huge headaches, and are only now being removed.
A part of me worries that the command line server will be another sort spot. Developing against the command line server will invariably be very different from a stand-alone web server. My concern is that, the people who will be helped by the simple server, will have more trouble than previously when it comes to deployment. The code that was working fine with the command line server, could behave differently when they get to the real deal. This is a frustrating thing to be faced with at the end of a project. Those people may even end up running the development server as their live server.
Every feature added to a program or programming language comes with costs related to maintenance, documentation and bug fixes. Is having this command line server going to be worth the maintenance and extra tickets it creates? I wonder if PHP team should be building another web server as well. There are a plethora of easy to install robust servers available. Is another web server really what PHP needs? To me the command line server represents a lack of focus. Instead of focusing on the things PHP already does well, and improving those, a web server is being bolted into the interpreter. I’m left wondering if having a built-in server will complicate the shared hosting solutions that made PHP as popular and ubiquitous as it is today. Allowing any user with access to
php the ability to start up a server could create problems in shared hosting environments.
At the end of the day, I’m not directly involved in the development of PHP, and have no real say in what happens with it. As a user of PHP, I personally would rather see support for things like short array syntax or annotations . Both of those proposed changes feel more useful to me than the command line server which is easily eclipsed in features and power by a standalone web server.