PHP, the popular cross-platform Web development tool, shows great versatility. It offers power to the pro and simplicity to the novice. It runs on many hardware and software platforms, including Windows, Mac, UNIX, and System i. PHP offers other benefits as well: - Requires no licensing fees
- Runs many blogs and content management systems
- Can connect disparate systems with technologies such as SOAP
- Is endorsed by IBM
With DB2 support, powerful extensions and commands, and an architecture built for the web, PHP brings modern functionality to System i, simplifying tedious tasks. I recently worked with an HTML "textarea" (large text box) and had to split the text into chunks of a maximum size, observing word breaks. A mundane, time-consuming programming job? No—with PHP's wordwrap function, I needed only one line of code.
Zend ("The PHP Company"), which coordinates PHP's open-source development process, provides software and services that help companies use PHP effectively. Zend and IBM have cooperated since 2004 to offer PHP-oriented products for IBM's servers and databases, especially DB2. Programmers of All Levels Even people without programming experience can use PHP. According to Michael Pinette, Zend's vice president of business development, an early Zend customer was a non-programmer psychiatrist who used PHP to provide online access to mental-health topics, reference material, and social-networking portals for specific disorders. While such newcomers can use PHP, the language has enough advanced features to satisfy experts who wish to write sophisticated object-oriented applications. Zend's Added Value for System i Zend is a great match for System i because it brings the priorities of the System i community—stability, trust, safety, easy administration—to PHP. For IBM, Zend provides reliable PHP distributions and value-added components. According to Andi Gutmans, Zend's co-founder and vice president of technology, the company performs rigorous testing on PHP, selecting the most stable, best-performing versions for release in Zend Core. The first generally available (GA) release of Zend Core will include version 5.1.4 of PHP, says Gutmans. Gutmans estimates a six-month lag between the appearance of an open-source version of PHP and its Core release, "so it's stable and bulletproof, and customers won't hit walls."
Gutmans says Zend intends to port all its products to System i, treating the platform's users as first-class citizens, with the full solutions that other platforms enjoy. Support Zend users needing technical support can go to the Zend Support Center and obtain the first "support ticket"—continued help until a single problem is resolved—free. Subsequently, paid support is available at several levels, including 24x7 phone support. If a problem needs a collaborative resolution, Zend will work with IBM's engineers to solve it. In addition, free assistance may be requested at the Zend forums, with the usual delays and uncertainties inherent at volunteer help sites. System Requirements Zend Core requires i5/OS V5R4 or higher. Although IBM may eventually overcome technical hurdles to allow V5R3 support, this development is far from certain. System i users who want to try Zend in the near future would be wise to upgrade to V5R4, installing all relevant PTFs, especially the latest HTTP Server (Apache) PTF group.
Besides V5R4, users must install the following licensed programs:
| Zend Core Required Licensed Programs | | Description | Product Option | Licensed Program | | Portable Application Solutions Environment (PASE) | 33 | 5722SS1 | | Qshell | 30 | 5722SS1 | | System Openness Includes | 13 | 5722SS1 | | Digital Certificate Manager | 34 | 5722SS1 | | IBM Portable Utilities for i5/OS | *base | 5733SC1 | | OpenSSH, OpenSST, zlib | 1 | 5733SC1 | How to Install Zend Core After verifying the system requirements above, download Zend Core and Studio from Zend Network i5/OS page. Register as a Zend Network member to obtain access to Zend Core and Studio, discussion forums, support, and automatic software updates. When asked to select a "channel," click the link labeled "Zend Core," leading to a download page. From there, save the zip file to your hard drive. Extract the Zend Core files using an unzip tool such as ZipGenius. The extracted files include a save file, release notes, and a user guide.
For installation details, consult the release notes and user guide. Here are some additional tips (as of Version 1.3.1, the latest available at press time): - One "prerequisite" can be ignored. You do not need licensed program 5722ac3, Crypto Access Provider 128 bit. The functionality of this program has been absorbed into other programs.
- The installation uses IFS directory /usr/local. Create /usr/local before installing Zend Core. Make sure it is a true directory, not a symbolic link to another directory. (Confirm with the command WRKLNK '/USR/LOCAL' and then option 8, "attributes.")
- Sign on as QSECOFR for the installation process.
If any Web errors should occur, check for error messages in the following log files: /usr/local/Zend/apache2/logs/error_log .* or /usr/local/Zend/core/logs/php_error_log
Once you have installed Zend Core, the administration Web site will be available to you. The URL (by default) is http://www.myserver.com:8000/zendcore (myserver.com is any domain name assigned to your System i). Place your own PHP scripts in /www/zendcore/htdocs. They will run from http://www.myserver.com:89. Figures 1 and 2 show the Control Center and PHP Configuration pages.
Figure 1: Zend Core for i5/OS Control Center shows the status of PHP and the Web server. (Click images to enlarge.)
Figure 2: The Web-based PHP Configuration page is easier to read than old-fashioned PHP.INI files. Installing Zend Studio Download the appropriate version for you (Windows, Mac, or Linux) from the same page from which you downloaded Zend Core. The Windows version that I tried was a self-extracting executable file that installed easily. Menus in 5250 Mode Most of Zend Core's options are available on the Web-based administration interface. Some actions, though, can be run from a 5250 screen.
Main menu (shown in Figure 3): GO ZENDCORE/ZCMENU
Figure 3: The Zend Core 5250-based setup tool offers access to the Apache menu and a few other selections.
For direct access to the Apache menu: GO ZENDCORE/ZCAMENU
Administrators can control Zend Core's Apache server programmatically (for example, upon IPL) with these lines: Start: CALL ZENDCORE/ZCCAPCS001 Stop: CALL ZENDCORE/ZCCAPCE001 Restart: CALL ZENDCORE/ZCCAPCR001 Power from Extensions Extensions contain targeted bits of functionality. When compiled into PHP, they act as seamless parts of the language. Although anyone may write an extension and compile it into PHP, Zend has selected the best for inclusion in Zend Core, Gutmans says. Gutmans and his colleagues have included the most widely used extensions that meet their standards of quality, including, for example, ibm_db2 for optimized db2 access and gd for creating graphics dynamically.
Figure 4 shows the Extension Configuration page.
Figure 4: Extension Configuration allows extensions to be activated and configured.
At press time, Zend Core for i5/OS included the following extensions: bcmath, bz2, calendar, ctype, curl, db2, dom, exif, ftp, gd, tidy, gmp, ibm_db2, iconv, imap, ldap, libxml, mbstring, mcrypt, mhash, mysql, mysqli, openssl, pcntl, pcre, posix, session, shmop, simplexml, soap, sockets, spl, sqlite, standard, sysvmsg, sysvse, sysvshm, tokenizer, xml, xmlreader, xsl, zip, zlib, ming, and wddx. Alternative to mail() The first GA release of Zend Core will not support PHP's mail() command. System i does not have the "sendmail" program that mail() requires. Applications needing to send or receive email must use an alternative, such as the free PHPMailer class. Newcomers can get started quickly with the PHPMailer Tutorial. Integration with Traditional i5/OS Objects Generic, open-source distributions of PHP do not handle System i's special object types such as data areas, data queues, and message queues. Such distributions have no straightforward method to call i5/OS commands and programs written in RPG, CL, and COBOL. Zend Core is gradually filling this gap in the following ways: - Beta V2 (early July 2006) will have a "bridge" to RPG, CL, and other i5/OS native program objects.
- GA (late July) will have further bridges to data queues and message queues.
- Future releases may offer integration with other objects, such as data areas.
Database Access Zend Core's PHP distribution has several extensions that enable users to connect to databases on System i and other platforms, as shown in the following table.
| Database Extensions in Zend Core for i5/OS | | Extension | Description | Notes | | db2 | DB2 unified ODBC driver | The db2 extension provides a native db2 driver, accessed with the generic ODBC interface. | | ibm_db2 (recommended) | Native, optimized extension for DB2 | IBM's DB2 and System i engineers collaborated to make a high-quality, well-performing extension. Zend further tested it for reliability. | | PDO (not available) | PHP Data Objects | Not yet mature and stable enough for inclusion in Zend Core, PDO is an object-oriented, portable, generic interface to database drivers. | | mysql, mysqli | MySQL database access | Although PHP works well with the MySQL extensions, Zend Core does not include MySQL server software. Users who want MySQL should download it using instructions such as these. | One easy way to get started with the ibm_db2 extension is to go to an example from Zend's "Developer Zone," copy it, and adapt it. The SOAP example later in this article also uses ibm_db2. Zend Studio Is a Bonus That Speeds Development Zend Studio Professional is a graphical development environment intended to speed development and improve code quality. System i customers are getting this excellent package free while others pay $240 list price.
Available for Windows, Mac, and UNIX clients, Studio is a dazzling productivity booster. Anyone still using a simple text editor is urged to try Studio.
Consider the following examples from the Zend Studio feature list. The 5.2.0 beta version was used.
Interactive debugger (Figure 5): Studio has a sophisticated debugger. While code runs, the debugger shows the function's output (text and HTML format), values of variables, the call stack, and more.
Figure 5: In the debug demo, the Debug Output pane shows the accumulation of HTML or text source as code runs.
Coding errors are uncovered by the "real time" syntax checker (Figure 6):
Figure 6: The syntax checker noticed that a parenthesis was missing.
The code analyzer (Figure 7) produces a detailed error log.
Figure 7: The code analyzer found an unused variable, indicating a potential error.
SQL Support can work with structures and data of many database types (Figure 8).
Figure 8: Studio's SQL facility shows MySQL data from a Mambo content management system. Version and Source Code Control Zend Studio includes built-in clients for the popular Concurrent Versions System (CVS) and Subversion (SVN) version control systems. Administrators can download and install the open-source server portions from the Web. SVN, according to Gutmans, is superior to CVS and is adequate for teams of up to 10 developers.
Large teams might prefer a more robust version control system. Under discussion, Gutmans says, is the possibility that Zend will work with Eclipse and enterprise-grade version control such as IBM Rational ClearCase for more complex development environments. Zend Studio Simplifies SOAP Simple Object Access Protocol (SOAP) is an XML-based format that applications can use for exchanging data, primarily via HTTP. When two applications communicate, the data provider is called the "SOAP server." The data consumer is called the "SOAP client." How does the client know what services are offered by the server? A Web Services Description Language (WSDL) file defines the server's input and output. Zend Studio, with its ability to generate WSDL files, greatly speeds the preparation of SOAP services.
When I ran a quick personal test of PHP's SOAP extension and Zend Server's WSDL generator, everything worked easily. The example below, adapted from a sample by Zend's Shahar Evron, includes a server script (fruitserver.php) and a client script (fruitclient.php). Step 1: Create table with data to retrieve.
From STRSQL on a 5250 terminal, I created a table and gave it two records of test data:
CREATE TABLE FRUIT/APPLES (COLOR CHARACTER (10 ) NOT NULL WITH DEFAULT, NAME CHARACTER (20 ) NOT NULL WITH DEFAULT) INSERT INTO fruit/apples (color, name) VALUES('red', 'Red Delicious') INSERT INTO fruit/apples (color, name) VALUES('green', 'Granny Smith') )
Step 2: Create the server code, fruitserver.php (Figure 9).
The "at" signs (@) are part of phpDocumentor format, which helps generate WSDL markup. Note that fruitserver.php retrieves System i data using the ibm_db2 extension.
/** * Fruitserver.php * A sample SOAP server using a WSDL file generated with Zend Studio */
/** * This class describes a fruit-fact provider: It provides information about common fruits. It gets the information from an IBM System i DB2 database. * * Objects of this class be used internally in your application * as well as exposed as a SOAP service. * */ class fruitfacts { /** * Return the apple's name based on color. * * @param string $color * @return string */ public function appleNameFromColor($color) { $applename = ""; // intialize
// connect to System i DB2 database using default database name, user, password $conn=db2_connect("","",""); if (! $conn) { return db2_conn_errormsg(); } else { // query our System i DB2 database $sql="select name from fruit.apples where color=? "; $stmt = db2_prepare($conn, $sql); $result = db2_execute($stmt, array($color));
$row = db2_fetch_both($stmt); if ($row) { $applename = $row['NAME']; } db2_close($conn); } // the else of connection OK
// color not found if (! $applename) { $applename = "unknown apple"; } return $applename; }
}
// Set up the SOAP server, specifying wsdl file $server = new SoapServer('http://www.myserver.com:89/soaptest/fruitfacts.wsdl'); $server->setClass('fruitfacts');
// Handle SOAP requests $server->handle(); |
| Figure 9: Fruitserver.php contains one class, one function, and a few SOAP commands.
Step 3: Create the client code, fruitclient.php (Figure 10).
/** * Fruitclient.php * This is a sample script that uses the Fruitserver SOAP service. * * It demonstrates how to set up SOAP clients using WSDL files. */
// Try to set up the SOAP client and get the data try { // WSDL files can be read directly from the web! $client = new SoapClient('http://www.myserver.com:89/soaptest/fruitfacts.wsdl');
$color = array("red","green","purple"); $fruitname = array(null,null,null);
// pass in three colors, get three fruit names from the server $fruitname[0] = $client->appleNameFromColor($color[0]); $fruitname[1] = $client->appleNameFromColor($color[1]); $fruitname[2] = $client->appleNameFromColor($color[2]);
} catch (SoapFault $fault) { $errorMsg = "SOAP error {$fault->faultcode}: {$fault->faultstring}"; } ?>
Zend Brings PHP to IBM's i5/OS | Web Languages
padding: 2px; font-family: fixed; font-size: 9pt;"> Alan Seiden enjoys leading collaborative software projects and troubleshooting clients' perplexing problems. He has written many articles for usability and IT publications. Alan is vice president of the New York City Usability Professionals Association and a member of New York PHP.
| | Read More >> |
|
|
Last Updated on Tuesday, 11 July 2006 18:00 |
No Comments.
|
MOST POPULAR
| 1. |
tom snyder |
| 2. |
Costagliola |
| 3. |
subfile |
| 4. |
pdf |
| 5. |
vbscript |
| 6. |
afp2pdf |
| 7. |
data structure |
| 8. |
v6r1 |
| 9. |
xml |
| 10. |
percocet |
|