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…

This entry was posted in Open Source. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • http://red-piranha.blogspot.com/ Paul Browne

    Interesting Blog on UI (including Ajax) and using PHP at an enterprise Level (backed by Java).

    Do you have any more information about connection PHP and Java together in an Enterprise manner (current work interest ,hence the comment)?

    Would disagree with the comment that ‘Java seems to have more frameworks that actual apps’ , but seeing as the rest of the blog is good , I don’t want to start a series of flames :-)

  • http://www.sqlfusion.com Michael Frappier

    I would like to say that it is possible to use PHP at the enterprise level. We have build a PHP application server which allow developers to do so and have implemented it in a couple of Fortune 1000 companies to build intranets and extranets.

    I’d love to have your opinion about our technology if you can find the time.

  • http://www.atif.pk PHP freak

    Very True, In fact I was very disappointed when I found that I there is no way to share objects between requests as we can do in Java.

  • bimo

    hmmm… I haven’t been doing as much php programming for the past couple of years and I’m no cs major but could you use the $_SESSION array as this “global workspace.” But really, I always thought that global variables were to be avoided when possible b/c of the possibility of overwriting them. How about using persistent objects? (never tried this but it sounds like what you were looking for – http://ezcomponents.org/docs/tutorials/PersistentObject#class-overview)

    b