Enterprise PHP?

PHP is no doubt a great web programming platform. It is simple and fairly robust. About 90% of the time I want to find an open source web app for something, there are at least 5 written in php. It seems to have become the de-facto standard for simple web apps.

Currently I spend most of my time writing php because the contract I am currently on started with php as their web platform. I have written some pretty cool apps in php. With my most recent app I built a simple persistence framework in php. My background is Java and there are many great frameworks in Java for doing just about everything; from persistence to ui layout. Java definitely seems to have more frameworks that actual apps. That’s interesting and a topic for another day.

Anyways, can PHP really scale to an enterprise level? I discovered something very interesting recently which leads me to answer that question: “Not right now”. What I discovered kind-of shocked me. Perhaps I am just not searching Google for the right thing, but it seems to me that php has no mechanism for putting stuff into a global space where all threads / requests can access it. For example when I was writing my little php persistence framework I thought it would be cool to have a connection pool instead of having each request make a new db connection. Well… after searching, playing, programming, etc. for hours, it seems that there isn’t a way to do it. Ouch… So there is no way I can have like a true Singleton in php. Now that’s a big bummer because it means that things that get done over and over by many different requests can not really be pooled.

Ok, so for me that totally rules out php as an enterprise level solution. At least in Java if you are solely using Tomcat, your servlet can maintain a connection pool or similar services for you. If you are using JBoss you get that, JCA, Session Beans, etc… Lots of options for that kind of thing. So maybe I am just being dumb and there really is some way to do it. If that’s the case, please someone set me straight.

My next project will be to research having php connect to session beans so that I could use php for the web tier and java for the business tier. Sounds like fun…