DEVELOPER: Industry Standard
PHP for the Enterprise
By Rich Schwerin
Dynamic scripting for agile application development
PHP, the open source general-purpose scripting language often used for Web development, is a popular student on campus—especially corporate campuses. According to independent research firm Netcraft, PHP is used by more than 40 percent of the Web applications market, and more than 22 million Web sites have been built with it. So what's behind this growing popularity? Let's take a closer look, starting with PHP's beginnings.
Danish computer scientist Rasmus Lerdorf created Personal Home Page/Forms Interpreter (PHP/FI), a set of Perl scripts to track access of his online résumé, in 1995. PHP/FI had some of the basic functionality of today's PHP, including Perl-like variables, automatic form variable interpretation, and HTML-embedded syntax similar to Perl's, but it was simpler and less powerful. A later, larger C implementation of PHP Tools could communicate with databases.
"Today PHP is a recursive acronym for PHP Hypertext Processor ," explains Richard Rendell, product development director at Oracle. "It's come a long way in the past decade and is a powerful language for server-side scripting. PHP is a viable alternative to ASP [Active Server Pages] and JSP [JavaServer Pages]."
Rendell adds that before PHP, Web scripting was done mostly in Perl. "For a novice, Perl has a very challenging syntax and can be obtuse," says Rendell. "Perl is a powerful language, but it's not easy for people to learn—it wasn't written from the ground up to work with the internet. The internet needed a simple and highly productive scripting language, and that's where PHP came in."
Putting PHP to Work
Most developers today use PHP in Web applications from the simplest guest book or blog to shopping carts, content management systems, and other complex applications. PHP scripts are used for server-side scripting, command-line scripting, and desktop applications. With PHP server-side scripting, developers can do almost anything—generate dynamic page content, collect forms data, handle cookies—and more.
"As the PHP language has matured, its power has evolved. You can do more things with it, and we've started to see the beginning of enterprise PHP applications. These include CRM products such as SugarCRM; collaboration suites such as eGroupWare; and content management systems such as Mambo, PostNuke, and many others," says Rendell. "We're seeing PHP in an enormous number of areas, because anything you can do on the internet you can do in PHP. It's used to deliver most of the front-end, browser-centric applications on the Web today."
PHP runs on most operating systems, including Linux, UNIX, Microsoft Windows, Mac OS X, and others, and it supports most Web servers, including Apache, Zeus Web Server, lighttpd, and Microsoft Internet Information Server. In addition to HTML, PHP can output images, Adobe Acrobat files, Macromedia Flash, XML, and more—all of which can be autogenerated. There are many PHP extension libraries that perform common functions, and there are communities that support PHP libraries, including the PHP Extension and Application Repository, which provides, maintains, and distributes a structured library of common function and other code, and the PHP Extension Community Library, which offers C extensions that expand PHP's core functionality.
"The dynamically-typed-language approach PHP offers is gaining momentum for agile development," adds Rendell. "PHP is ideal for getting Web sites up and running very quickly and is now extending into complex Web applications."
For example, Rendell cites the million lines of PHP code running against an Oracle database at Trader Electronic Media, which operates AutoMart.com, the internet's largest dealer-only automotive Web site. AutoMart.com uses PHP and Oracle to deploy this high-volume site—a scalable, secure, open source Web site that posts more than half a million ads and manages more than 2.5 million visitors each month.
PHP, Java, and Ajax
PHP's streamlined functionality is essential for organizations with limited development resources and intense deadline pressure. With PHP even nondevelopers can be productive in days, and developers with experience in C, C++, or Java can be productive in hours.
"Often there's a great amount of engineering that goes into building a Java application when a simpler PHP Web application might suffice," says Rendell. "The J2EE framework, for example, is something the PHP community tends to hold up as a fairly complex entity."
PHP's basic tenet, explains Rendell, is to be fast and easy to use, so developers can be very productive very quickly. This agile approach lends itself to the front end of more-complex Java applications. "JSP is just one language that accesses Java objects. PHP also integrates with Java, so it can be used as the scripting language for activating Java logic, just like JSP," explains Rendell. "We're seeing an increased amount of integration between PHP and Java, where a Java application is running on the back end and PHP is running on the front end."
Zend Core for Oracle Database
Not long ago, installing PHP with Oracle was a time-consuming process. Developers had to download a variety of components—PHP, Apache, Linux, and the Oracle extension for PHP—install an Oracle client, and configure everything, which often led to integration issues.
To address the challenges facing developers who need to build their own multicomponent stack, Oracle offers Zend Core for Oracle, a free, integrated tool designed to help developers build and deploy database-driven PHP-based applications for Oracle. A fully tested and supported PHP 5 distribution, Zend Core for Oracle includes tight integration with Oracle Database 10g client libraries. It also contains a refactored OCI8 driver with substantial code improvements and new connection controls.
"Zend Core for Oracle is a prebuilt binary of all those technologies," says Rendell. "For example, on Linux we have all of the Linux parts of the stack, including PHP and the Oracle Instant Client, built into a single distribution configured on the platform through a basic Web browser interface. You're up and running in minutes."
PHP 5, PHP 6, and Beyond
"The overall direction for PHP as it matures is to make its way into more enterprise-level applications as organizations take advantage of the agility and ease of learning that PHP affords," says Rendell. "With PHP 5, development organizations are able to create more-powerful applications in much less time, which reduces costs."
PHP 5 includes features to address enterprise needs, including an updated Zend engine, extended XML, Web services, and enhanced database support. The engine, a core component that powers PHP, includes more than a dozen object-oriented development features that allow organizations to create maintainable component-based enterprise applications. XML support includes general XML extensions written to use the Gnome Project's XML and XSLT libraries. A new SimpleXML feature enables developers to manipulate XML files as if they were PHP objects. PHP 5 also includes a SOAP module, allowing interoperability with Web services, and extended database support that takes advantage of the new engine's object-oriented extensibility.
As with any student on campus, popularity ebbs and flows, and successful students—and standards—must evolve and grow if they're to retain that popularity. So what can developers expect in PHP 6?
"Frameworks are being built at the moment, and there are PHP community projects under way," says Rendell. "The language will be adopting features such as Unicode support, which is planned for PHP 6. This is an important part of becoming an enterprise-grade language, and we see PHP establishing itself as one of the three main pillars of technology for building Web applications: Java, .NET, and PHP."
Rich Schwerin (email@example.com) is a product marketing manager with Oracle Technology Marketing.