In these days of open XML standards and rapid technological change, what counts online is flexibility and pace.
PHP‘s ability to handle SOAP as well as integrate with other languages and platforms, including Java, COM and .NET modules makes it the “third way” for presentation of N-Tier applications.
The big news these days, for both Intranets and the Internet as a whole is frameworks; namely Sun’s J2EE and Microsoft’s .NET.
Both frameworks are (like any new technology) being promoted as the cure to any common IT ailment, particularily if you plan to start a global business trading in household pets. There is much to gain, in terms of decreased development times, integration of legacy applications and more.
The key concept being sold is N-Tier, as we examined in A Quick Intro to N-Tier, combined with notions of aggregating all your legacy applications, be they written in Java, C++ or even old IBM mainframe applications written in TPF, into a common platform, with aide of technologies like SOAP.
Of course both vendors offer a total solution “for all your needs”. Where this get’s interesting, at least where PHP is concerned, is at the Presentation Logic layer in an N-Tier architecture.
Although both frameworks claim use of open standards, each has a “catch” which could either tie you to a particular platform or standard.
With J2EE it’s in the use of inter tier messaging standards only supported in Java. For .NET it’s in the fine print: “Requires Windows”.
When considering what to choose for deploying N-Tier applications in a web based environment (i.e. the Presentation Logic tier), issues such as cost, flexibility (both in terms of platform and programming methodology) and ease of development become important.
The solutions offered for the Presentation Logic layer by each framework are;
JSP / Servlets
With J2EE the presentation logic technology is is either JSP (Java server pages) or Servlets, typically communicating with J2EE standards like Enterprise Java Beans. Pros + Cross platform + Uses Java class library + Access to COM / .NET modules via third party solutions
[Note: Replaced unjustified remarks highlighted in comments below] Cons - Encourages language “lock in” through use of inter-tier messaging protocols only supported by the J2EE standard. - The main stream application servers (SunOne, WebLogic, WebSphere) come with significant price tags. Open source or “nearly free” alternatives do exist though, such as JBoss, Tomcat, Resin and Jonas (A complete list of alternatives). Although choice may be a good thing, a side effect may be fragmentation of technical support expertise. - Typicially requires additional hardware investments to get same performance as alternatives, although this should not be a problem on “native” environment (e.g. Solaris and other common Unix flavours)
Cost - Using a “main stream” application server to build a JSP/Servlet environment for web deployment is arguably the most expensive choice, compared to alternatives. This can be avoided using an Open Source option.
ASP.NET
Microsofts solution is ASP.NET, basically a templating solution backed by a .NET language, where the inter-tier messaging is intended to be done using SOAP. Pros + Nice library for easy construction of web interfaces (web controls). + Nice tool, if you’re into GUI IDE’s: Visual Studio + Backward compatible with most Windows based code.
Cons - One platform (Windows), one web server (some flavor of IIS) Read the Gartner Advisory]. - Vendor lock in via the Windows platform. - Encouraging use of SOAP for interop which, despite the hype, still has some big “ifs”, such as security. - Encourages use of templates (ASP.NET being a template engine) which can quickly result in nightmare applications, in terms of reuse and maintanence. - Still a young technology, ungoing significant change and stabilization.
Cost - cost comes in with the supporting environment, ASP.NET being a vehicle for MS to sell other products, such as web servers (.NET server), server operating systems, Exchange server and so on (plus the development tools such as Visual Studio). For one persons cost assement try here
Note: - some may say it’s unfair to call .NET a “one platform” technology, given Mono for example. In answer I’d simply say how many enterprise websites do you know running Chillisoft behind their old Active Server Pages?
PHP: The Third Choice
PHP is vastly underestimated by many, despite being the Internets number 1 server side language.
Where PHP has amazing potential for future N-Tier environments is in being able to aggregate practically any kind of legacy application on any platform into a unified “Presentation Logic” layer... for free (i.e. no commercial licenses).
PHP has massive support, both in the form of it’s active community as well as companies like Zend and NuSphere. offering support contracts.
PHP has an ever growing range of supporting development tools, with Macromedia now supporting it in Dreamweaver MX, an Eclipse IDE plugin in progress, support for PHP in Doxygen, Sybase working on PHP support in PowerDesigner, etc. etc. etc.
PHP Interop
PHP already has the means to natively access most other environments ( see the (*deprecated link* links), most importantly Java and .NET / COM.
PHP also has excellent support for the new breed of (*deprecated link* messaging protocols.
Web Services are a great concept and will, no doubt, become a widespread technology in the near future. Unfortunately, to use web services, you need a client and a server. In other words, if you want to integrate your old C++ applications with your new web platform, you need to provide some kind of web services API on top of the legacy code.
But the application already had an API so why should you have to bother adding yet another if you can avoid it?
Here’s your options with PHP;
+ Java Integration + COM Integration + .NET Integration + C/C++ Integration + CORBA Integration + Tuxedo Connectivity + And many more...
Of the above list, those which “integrate” with PHP provide a means to instantiate objects from those environments within PHP scripts.
So, for example, that Java class which encapsulates business logic... the client to the API could easily be PHP. You could equally use the Enterprise Java Bean API from PHP.
As the above image attempts to demonstrate, PHP can be used to aggregate many environments into a single web interface.
The Zend and PHP Group are well aware of the importance of PHP‘s ability to integrate with other languages and technologies, as Zeev Suraski’s recent article on The Object-Oriented Evolution of PHP highlights, while introducing PHP 5.0;
Most notable is the revolutionized interaction with external component models, such as Java, COM/DCOM and .NET via overloading. PHP 4.0 was the first version to introduce this sort of integration, but the new implementation is much quicker, more complete, more reliable and far easier to maintain and extend. These elements mean that PHP 5.0 will play very nicely in your existing Java or .NET based setup
PHP: A real alternative
So to summarize...
Pros + Cross platform both in terms of Operating System and web server (e.g. runs well on Apache and IIS). + No lock in, in terms or underlying platform (OS/Webserver) or inter-tier messaging standards. PHP even has a technology called “ActiveScript” in development which will allow you to invoke PHP code from ASP or ASP.NET scripts. + More web “functionality” than any alternative (ask your vendor if their offering will render Flash and PDF, for example) + Ability to natively integrate with both the “big” frameworks, as well as legacy C/C++ and COM APIs. + Easy to deploy. You probably already have Apache somewhere serving simple web pages. Your “entrance” into PHP is probably less than 1 hours work. + Easy to learn and intuitive for developers used to other languages. + Rapid application prototyping Scales to enterprise web environments + The largest collection of supporting web based Open Source applications and libraries. + Rapidly evolving language, paying close attention to user feedback (as opposed to Java, for example). + Massive installed base makes PHP very responsive to bugs and security holes.
Cons - Requires enlightened management (of the sort that don’t get nervous when you mention “free”). - PHP developers need to be prepared for assault from “theoreticians” in other languages. Just remember: “Well then this (point browser at PHP page) must be impossible then...”.
Put another way, although PHP is not a language which conforms to the idea that “everything is an object”, it does have full support for the three key ingredients of any object oriented language, namely Encapsulation, Inheritance and Polymorphism. Given the nature of the environment PHP is designed for, namely the web and a range technologies from HTML and XML to Flash, there are many good reasons why having a language, which sacrifices strict programming for flexibility, is a very good thing.
Given the ever changing nature of technology on the Internet, it could be said that no web based application ever gets beyond the stage of being a prototype. In such an environment, having a language gear to delivering fast results as well as offering the elements required for “good programming practices” is important.
It’s a subject for perpetual and heated debate, for which the final verdict can only be measured in terms of end results. Time will tell...
Cost 100% Free. Being designed first and foremost for Apache and Linux, putting together a solid web server to run PHP on comes only with hardware costs, plus staff costs. Overall, as a recent MS-backed study shows, for web servers, you can’t beat LAMP for price.
In Summary
While the big vendors are touting the potential benefits their online solution could, PHP is already doing it. Today. It simply doesn’t get any cheaper, easier or more flexible.
In these days of slim IT budgets, “going online” is seen as high risk by many. PHP allows you to cut that business risk to a minimum, requiring no initial outlay, minimal investment in training (you really can learn this language on your own) while getting the most out your existing resources. Yahoo, for example, came to exactly the same conclusion, while considering who to update their servers. Other big names using PHP (there’s a long long list) include Deutsche Bank (the worlds largest), Dresdener Bank, Cisco, Sprint, Nortel Networks, Lycos, Siemems, Deutsche Telecom, Motorola, Hewlett Packard, NTT, Rackspace, The US Bureau of Land Management, WallSteetOnline, The US General Accounting Office, Compaq, etc. etc. etc. (couple of sources here and here).
Before you spend $xxx,xxx on that application server to put your business online, spend a little time finding out how you’d do it with PHP. It might remind you of what the world wide web was origionally meant to be: free and easy.
Recommended Reading
PHP developer, Harald Radi (of http://www.nme.at) presented these two papers on “Creating Multi-Tier Web Applications with PHP” the PHPCon 2002;
Creating Multi-Tier Web Applications with PHP: Slides
Creating Multi-Tier Web Applications with PHP: Paper with PHP Examples
Disclaimer:
Of course I’m completely biased - this is phpPatterns after all.
