PHP Zend For i5OS
PHP Zend For i5OS
PHP Zend For i5OS
Gary Mullen-Schultz
Melissa Anderson
Vlatko Kosturjak
ibm.com/redbooks
SG24-7327-00
Note: Before using this information and the product it supports, read the information in Notices on
page vii.
Contents
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
The team that wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Become a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .x
Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .x
Chapter 1. Welcome to PHP on i5/OS! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1 Welcome! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.1 IBM and Zend Core. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.1.2 Zend Core for IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Previous support of PHP on i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Current support of PHP on i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.1 Zend Core for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.2 Zend Studio for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3.3 Zend Platform for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 How i5 implementation differs from Zend Core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 Benefit to developers and customers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
2
2
2
3
3
3
4
4
5
5
7
8
8
9
9
Chapter 3. Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.1 Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2 Installing Zend Core for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.1 Before you begin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.2 Installing the Zend Core for i5/OS product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.3 Starting the Zend Core for i5/OS environment . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.4 Verifying the installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.5 Common installation errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.6 Reinstalling Zend Core for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.7 Uninstalling Zend Core for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.8 Product structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.9 Runtime environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3 Configuring Zend Core for i5/OS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3.1 Administration tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4 Configuring multiple instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.4.1 Multiple i5/OS Apache instances, one PHP server . . . . . . . . . . . . . . . . . . . . . . . .
3.4.2 Multiple i5/OS Apache instances, multiple PHP servers. . . . . . . . . . . . . . . . . . . .
3.4.3 One i5/OS Apache instance, multiple PHP servers . . . . . . . . . . . . . . . . . . . . . . .
3.5 Backing up Zend Core for i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
11
12
12
12
15
18
19
21
21
22
22
24
26
26
30
30
32
34
36
iii
iv
41
41
43
43
45
45
46
47
48
49
49
50
54
55
56
59
60
60
69
71
71
71
71
72
75
77
78
79
80
80
80
80
81
81
83
85
85
86
Chapter 7. Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1 Security considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.1 SSL configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.2 Access to directory structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.3 Reverse proxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.4 User profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7.1.5 More information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
88
88
88
89
89
90
Chapter 8. Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1 Performance tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.1 Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.2 i5/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8.1.3 i5/OS PASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
92
92
93
93
105
106
106
106
109
110
110
110
110
111
113
114
116
118
118
118
Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Other publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Online resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How to get IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Help from IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
119
119
119
119
120
120
Contents
vi
Notices
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult
your local IBM representative for information on the products and services currently available in your area. Any
reference to an IBM product, program, or service is not intended to state or imply that only that IBM product,
program, or service may be used. Any functionally equivalent product, program, or service that does not
infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document. The
furnishing of this document does not give you any license to these patents. You can send license inquiries, in
writing, to:
IBM Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of
express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made
to the information herein; these changes will be incorporated in new editions of the publication. IBM may make
improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time
without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any
manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the
materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring
any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products and cannot confirm the
accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the
capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them
as completely as possible, the examples include the names of individuals, companies, brands, and products.
All of these names are fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrate programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs in
any form without payment to IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating platform for which the sample
programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore,
cannot guarantee or imply reliability, serviceability, or function of these programs.
vii
Trademarks
The following terms are trademarks of the International Business Machines Corporation in the United States,
other countries, or both:
Redbooks (logo)
developerWorks
eServer
ibm.com
iSeries
i5/OS
z/OS
AIX
Cloudscape
DB2 Connect
DB2 Universal Database
DB2
DRDA
Informix
IBM
POWER
Rational
Redbooks
System i
System i5
System z
WebSphere
viii
Preface
This IBM Redbook will help you install, configure, and become productive with PHP on
System i using Zend Core for i5/OS and Zend Platform for i5/OS. If you are evaluating
PHP, this book will also help by providing background information and comparisons with other
tools.
Some of the topics addressed include:
Installation, configuration and administration
Application development
Strategies to access DB2 for i5/OS and MySQL data from your PHP applications
Security, performance, troubleshooting, and more
Emphasis has been placed on highlighting i5/OS-specific functions and features in this book
rather than those generic to PHP on all platforms.
ix
Whei-Jen Chen
ITSO San Jose
A special thanks to Alan for his thorough and thoughtful comments and contributions to the
book:
Alan Seiden
Strategic Business Systems, Inc.
Comments welcome
Your comments are important to us!
We want our Redbooks to be as helpful as possible. Send us your comments about this or
other Redbooks in one of the following ways:
Use the online Contact us review redbook form found at:
ibm.com/redbooks
Send your comments in an e-mail to:
redbooks@us.ibm.com
Mail your comments to:
IBM Corporation, International Technical Support Organization
Dept. HYTD Mail Station P099
2455 South Road
Poughkeepsie, NY 12601-5400
Chapter 1.
1.1 Welcome!
Zend and IBM have partnered to deliver Zend for i5/OS, a complete, all-in-one PHP
development and production environment that is fully integrated with the innovative i5/OS
platform. Zend for i5/OS includes Zend Core, Zend Studio, and Zend Platform to provide
System i businesses with a complete solution for the development and management of
modern Web applications. For System i businesses, Zend for i5/OS is one of the most
productive and cost-effective routes to rapid Web enablement and the integration of Web
Services supporting SOA.
Bundled IBM Cloudscape server and DB2 drivers for enterprise database Web application
deployments
Easy to access documentation
Support options available from Zend
IBM and Zend are collaborating on development and support for the PHP environment. This
collaboration reinforces the IBM commitment to the open source community. IBM has
submitted newly introduced and optimized DB2 and Cloudscape extensions for PHP to the
PHP community and integrated them into Zend Core for IBM.
This expands the IBM investment in open source by helping developers more effectively
create and deploy applications. The availability of Zend Core for IBM significantly enhances
developer support for the IBM Cloudscape open-source database, because PHP is one of the
most popular Web programming languages in the world. In addition, the Zend Core PHP
maintenance process ensures better stability and reliability of PHP as a result of the intensive
testing and bug fixes that are posted back to the PHP community of users across all facets of
the market.
includes native support for XML and Web Services in support of the increasing adoption of
SOA applications. It delivers a rapid development and deployment foundation for
database-driven applications and offers an upgrade path from the Cloudscape database to
the DB2 by providing a consistent API between the two.
Find more information about Zend for i5/OS at:
http://www.zend.com/products/zend_core/zend_for_i5_os
Besides the software downloads, that site contains additional information such as data sheets
and white papers about Zend Core for IBM. Developers should take a look at the Developer
Zone, which features tutorials, documentation, discussion forums, and much more. Developer
Zone is located at:
http://www.zend.com/developers.php
Zend Core for i5/OS supports PHP 5.1 on i5/OS V5R3 (in beta at the time this document was
written) and V5R4, and was released on July 31, 2006.
Some of the benefits of Zend Core for i5/OS include:
IBM DB2 native support through ibm_db2 and ODBC PHP extensions
Zend Network automatic online updating services
Web administration GUI
Zend Core for i5/OS setup tool
Access to existing native i5/OS resourcesCL and RPG programs, data areas, and
morevia the PHP Toolkit
Support for PHP 5.1.6 and Apache on i5/OS
Easy installation
Certified PHP, fully supported by Zend
Numerous popular PHP extensions, allowing support for thousands of PHP applications
and scripts
Instant online debugging and error fixing against Zend Core for i5/OS
Supports PHP 5
Troubleshooting with PHP Intelligence
Syntax completion
SQL tool for exploring your DB2 for i5/OS and MySQL databases
Superb support for SOAP, with automatic creation of WSDL files
Works exclusively with Zend Core for i5/OS
Important: Zend Platform for i5/OS is not a no-charge product like Zend Core and Studio
for i5/OS.
Zend Platform for i5/OS brings additional value, including:
Chapter 2.
Overview of PHP
This chapter describes PHP and discusses its history and popularity. It also covers some
advantages and disadvantages in comparison to Java and general recommendations for
solving some of the disadvantages of PHP.
more than 12,000 PHP scripts; or http://www.phpclasses.org, which provides many PHP
classes), PHP extensions (see http://pear.php.net), and assorted documentation.
In addition, PHP does not use a lot of system resources while offering high speed of
execution, stability, and extensibility, which are just some of the reasons why PHP is so
successful and still growing in popularity. Bringing this success to i5/OS makes sense for both
traditional PHP developers and long-standing i5/OS programmers.
10
Chapter 3.
Administration
In this chapter we provide an introduction to administering Zend Core for i5/OS, including
installation, configuration, administration tools, managing the runtime environment, and
backing up the product.
11
3.1 Packaging
Zend provides PHP functionality on System i through Zend Core for i5/OS.
12
2. On the Work with Licensed Programs display, type option 10 (Display installed licensed
programs).
3. Press F11 twice to display the product options.
4. Ensure that the software listed in Table 3-1 is installed.
Table 3-1 Software prerequisites
Licensed
program
Option
Description text
5722SS1
*BASE
5722SS1
13
5722SS1
30
Qshell
5722SS1
33
5722SS1
34
5722DG1
*BASE
5722JV1
*BASE
5722JV1
Option 5 or 6
5722SC1
*BASE
5722SC1
Option 1
Digital Certificate Manager is used for configuring secure sockets layer (SSL).
IBM Developer Kit for Java (5722JV1) is not required to run Zend Core for i5/OS. It is required
to support the IBM Web Administration for i5/OS tool that is shipped with IBM HTTP Server for
i5/OS (5722DG1). The Web Administration tool is a graphical browser-based tool that you can
use to administer HTTP servers. Java is also required if you plan to use the Java Bridge functionality included with Zend Platform for i5/OS (see Chapter 6, Java Bridge support on page 79
for more details).
2
Chapter 3. Administration
13
Use the Display PTF (DSPPTF) command (for individual fixes) and the Work with PTF
Groups (WRKPTFGRP) command (for group fixes) to check what fixes have been applied to
your system.
You should order and install any missing fixes prior to installing Zend Core for i5/OS.
Chapter 3. Administration
15
You must first register with Zend.com. During this process, you create a Zend Network
user ID and password, which you can use to log in to the Zend download pages and to
update the product after it has been installed. You can provide this user ID and password
to the product during installation or from the setup menu after installation.
Download the Zip file to your workstation system.
2. Extract the Zip file to a temporary directory on your workstation.
The following files are extracted:
zcoresavf.savf
A save file that contains the Zend Core for i5/OS product.
Release_notes
Readme
Zend_Core_User_Guide_i5OS.pdf
Includes installation instructions, getting-started information, and
documentation about the Zend Core console.
3. Log on to the i5/OS system with a user profile of *SECOFR user class with all special
authorities.
4. Create a save file with the following command:
CRTSAVF FILE(QGPL/ZCORESAVF) TEXT(Zend Core product save file)
5. Verify that FTP is running on your i5/OS system by typing:
NETSTAT *CNN
Look for FTP or 21 in the Local Port column.
6. On your workstation, open a command prompt and transfer the Zend Core save file to the
i5/OS system:
a. Change directory to the directory that contains the files you extracted from the ZIP file,
for example:
cd temp
b. Run the FTP command, specifying the name of your i5/OS system, for example:
ftp systema
c. If requested, enter a valid user profile and password.
d. Enter the bin command to specify a binary transfer.
e. Transfer the save file to the i5/OS system:
put zcoresavf.savf
f. When the transfer has completed, enter the quit command.
7. Return to your 5250 session and run the Restore Licensed Program (RSTLICPGM)
command to install the product:
RSTLICPGM LICPGM(1ZCORE5) DEV(*SAVF) SAVF(QGPL/ZCORESAVF)
Note: The value of the licensed program (LICPGM) parameter starts with the number 1,
not the capital letter i.
16
Alternatively, you can type RSTLICPGM and press F4 to prompt the command parameters.
Press F10 to view additional parameters. Specify values for Product, Device, Save file,
and Library, and press Enter.
Restore Licensed Program (RSTLICPGM)
Type choices, press Enter.
Product . . . . . . . . . . . .
Device . . . . . . . . . . . . .
+ for more values
Optional part to be restored . .
Type of object to be restored .
Language for licensed program .
Output . . . . . . . . . . . . .
Release . . . . . . . . . . . .
Replace release . . . . . . . .
Volume identifier . . . . . . .
+ for more values
Sequence number . . . . . . . .
End of media option . . . . . .
Save file . . . . . . . . . . .
Library . . . . . . . . . . .
F3=Exit F4=Prompt
F24=More keys
F5=Refresh
1ZCORE5
*SAVF
Character value
Name, *SAVF
*BASE
*ALL
*PRIMARY
*NONE
*FIRST
*ONLY
*MOUNTED
*BASE, 1, 2, 3, 4, 5, 6, 7...
*ALL, *PGM, *LNG
Character value, *PRIMARY...
*NONE, *PRINT
Character value, *FIRST
Character value, *ONLY, *NO
*SEARCH
*REWIND
ZCORESAVFZ
QGPL
1-16777215, *SEARCH
*REWIND, *LEAVE, *UNLOAD
Name
Name, *LIBL, *CURLIB
F12=Cancel
More...
F13=How to use this display
8. After a few minutes, the installation wizard starts. During the wizard, you perform the
following actions:
Read and accept the license agreement.
Provide a password that you want to use to access the Zend Core Web Administration
Console. This password is arbitrary and not tied to any user profile or ID.
Enter your Zend Network user ID and password (which you used to download the
product Zip file). Providing this information enables you to set up automatic updates for
the Zend Core for i5/OS installation. You do not have to enter your user ID and
password at this time; you can specify this information later.
Note: If you press F3 or make a choice that causes the installation wizard to exit
before the installation process is complete, follow the steps in Checking for existing
product directories and library on page 14 to clean up your system. Note that
pressing F3 from the "Zend Network ID" prompt does not terminate the installation
processit continues without configuring this specific feature.
Chapter 3. Administration
17
2. On the command line, type 5 to select the Service Management menu, and press Enter.
The Service Management menu appears, as shown in Figure 3-3 on page 19.
18
3. On the command line, type 1 to select the option to start the Zend Core subsystem, and
press Enter.
This action starts the jobs that run in the ZEND subsystem.
4. Starting the ZEND subsystem causes all necessary Core and Platform jobs to be started.
5. Verify that the appropriate jobs are running.
a. First, check that the IBM HTTP Server for i5/OS instance (ZENDCORE) is running.
On the command line, enter the following command:
WRKACTJOB SBS(QHTTPSVR)
A list of active jobs running in the QHTTPSVR subsystem appears. Ensure that five
jobs named ZENDCORE appear in the list. (You might need to press the PageDown
key to scroll through the list.)
b. Press F3 to return to the Service Management menu.
c. Check that the Zend Core jobs are running. Enter the following command:
WRKACTJOB SBS(ZEND)
A list of active jobs running in the ZEND subsystem appears. Ensure that one or more
instances of the following jobs appear in the list:
I5_COMD
ZC_STR_PRN
ZENDCOREAP
19
To verify the installation, ensure that PHP files can be processed. Probably the easiest way to
do this is to access the Zend Core for i5/OS administration console. The console is a
browser-based tool that is used to administer the Zend Core product. The tool is written in
PHP, so if the console is functional, the PHP environment is working.
To access the Zend Core for i5/OS administration console, perform the following steps:
1. Open a Web browser and enter the following URL:
http://<server_name>:89/ZendCore
where <server_name> is the host name or IP address of your i5 system.
2. A redirection page appears. In a few seconds, the Zend Core console logon page
appears, as shown in Figure 3-4.
Log in to the console with the administrative password you entered in the installation
wizard.
Figure 3-4 The Zend Core for i5/OS console logon page
20
After you have verified that the console is functioning, click Logout in the upper-right corner
of the console and close the browser window.
After you have corrected the problem, make sure you remove any product files that were
created during the failed installation. See Checking for existing product directories and
library on page 14 for more information.
Chapter 3. Administration
21
Library
The ZENDCORE library contains i5/OS-specific code for installing, configuring, and starting
the product environment.
User profiles
The Zend Core installation creates the user profiles listed in Table 3-2.
Table 3-2 Zend Core user profiles
22
User profile
User class
Special
authorities
Group
profile
ZENDADMIN
*SECOFR
(ALL)
*NONE
ZENDTECH
*USER
*NONE
*NONE
NOBODY
*USER
*NONE
NOGROUP
Description
User profile
User class
Special
authorities
Group
profile
*USER
*NONE
*NONE
NOGROUP
Description
Group profile for the NOBODY
user profile, specified in the i5/OS
PASE Apache HTTP Server
configuration
Important: Passwords are not defined for these user profiles, so they cannot be used to
sign on to the system.
Zend Core for i5/OS uses the following system-supplied user profiles:
QSECOFR
The controlling job for the ZENDCOREAP group of jobs is run under QSECOFR.
QTMHHTTP
The jobs supporting the IBM HTTP Server for i5/OS server (ZENDCORE) run under the
default HTTP server user profile. These jobs run in the QHTTPSVR subsystem.
QTCP
The job that supports the i5 Toolkit for Zend Core runs under the QTCP user profile.
Directories
Zend Core for i5/OS uses these main directory structures:
/www/zendcore
This directory contains your IBM HTTP Server (powered by Apache) for i5/OS HTTP
server instance. The subdirectories of this directory are as follows:
/www/zendcore/conf
This directory contains the httpd.conf file, which represents the configuration of the
ZENDCORE server instance.
/www/zendcore/htdocs
This directory is the document root for both the IBM HTTP Server instance and the
i5/OS PASE Apache server instance. Your PHP files and other application resources
reside in this directory.
/www/zendcore/logs
This directory contains the log files (access_log and error_log, by default) for the
ZENDCORE server instance
/usr/local/Zend
This directory contains license and product information files. It also contains two important
subdirectories:
/usr/local/Zend/apache2
This directory contains the Apache HTTP Server that runs in i5/OS PASE. Several
subdirectories contain the product binaries. From an administrative standpoint, you
only need to be familiar with the following subdirectories:
/usr/local/Zend/apache2/bin
This directory contains binaries for the Apache HTTP Server instance.
Chapter 3. Administration
23
/usr/local/Zend/apache2/conf
This directory contains the httpd.conf file, which represents your i5/OS PASE
Apache server instance.
/usr/local/Zend/apache2/logs
This directory contains the product log files (access_log and error_log, by default).
/usr/local/Zend/Core
This directory contains the Zend Core product. Of the various subdirectories, the
following directories are important:
/usr/local/Zend/Core/bin
This directory contains binaries for the Zend Core product.
/usr/local/Zend/Core/etc
This directory contains the configuration files for the PHP environment, most
notably the php.ini file.
/usr/local/Zend/Core/logs
This directory contains the Zend Core product log files (php_error_log and
ini_modifier_log).
Components
To understand the technical details of Zend Core for i5/OS administration, it is helpful to take
a high-level look at the runtime components (pictured in Figure 3-6) and how they interact
with each other.
These components make up the PHP environment runtime provided by Zend Core for i5/OS:
IBM HTTP Server or i5/OS
Client requests are received by the IBM HTTP Server for i5/OS instance. The server
instance is named ZENDCORE, and it listens on port 89 by default.
24
The server is set up to pass all requests to the Apache HTTP server running in i5/OS
PASE. It also passes responses from the PASE-based Apache HTTP server back to the
users browser. In the first case, the i5/OS server acts as a proxy; in the second case, it
acts as a reverse proxy.
Using the native i5/OS HTTP server for the front end has many natural advantages:
The server instance can be managed with the IBM Web Administration for i5/OS tool.
An i5-specific tool, Web Administration offers point-and-click and wizard-based
configuration for your HTTP server.
Using the proxy/reverse proxy scheme provides an additional layer of defense between
the entry point into the server and where dynamic code is actually processed.
This configuration enables us to easily add secure sockets (SSL or HTTPS) to our
configuration. See Chapter 7, Security on page 87 for more details.
i5/OS PASE
i5/OS PASE is the AIX runtime in i5/OS. It is not an emulator: It takes advantage of the
hardware common to both i5 and p5 systems and the ability to switch between the
different runtimes. It allows AIX applications to be easily ported to System i5, providing
i5 ease-of-administration with the robustness of AIX applications.
Apache HTTP Server
Because Zend Core for i5/OS runs in the i5/OS PASE environment, a second HTTP server
instance is provided, also running in i5/OS PASE, to improve processing performance.
The Apache server provides the Web server environment for PHP applications. By default,
it listens on port 8000.
As previously stated, requests are forwarded to the Apache server for processing by the
IBM HTTP Server for i5/OS instance. The Apache server is configured to only accept
requests from the local system (127.0.0.1).
Zend Core for i5/OS
Zend Core provides the PHP runtime environment. Requests for PHP processing is
passed from the Apache HTTP Server to Zend Core. The PHP engine in Zend Core
interprets the PHP code and performs any necessary processing, such as querying a
database or accessing system resources.
The PHP engine replaces the PHP code with the results of its processing and returns the
response to the Apache HTTP Server to be sent back through the IBM HTTP Server to the
user.
i5/OS data and resources
PHP applications can access i5/OS data and resources such as program (*PGM) objects,
files, data queues, commands, data areas, and so on. Various application programming
interfaces (APIs) can be used to programmatically access these resources, which are
discussed in Chapter 4, Application development on page 39.
Chapter 3. Administration
25
Opt
Subsystem/Job
QHTTPSVR
ZENDCORE
ZENDCORE
ZENDCORE
ZENDCORE
ZENDCORE
ZEND
I5_COMD
ZC_STR_PRN
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
ZENDCOREAP
Current
User
QSYS
QTMHHTTP
QTMHHTTP
QTMHHTTP
QTMHHTTP
QTMHHTTP
QSYS
QTCP
ZENDADMIN
QSECOFR
QSECOFR
NOBODY
NOBODY
NOBODY
NOBODY
NOBODY
NOBODY
NOBODY
NOBODY
NOBODY
Type
SBS
BCH
BCI
BCI
BCI
BCI
SBS
ASJ
BCI
BCI
BCI
BCI
BCI
BCI
BCI
BCI
BCI
BCI
BCI
BCI
CPU % Function
.0
.0 PGM-QZHBMAIN
.0 PGM-QZSRLOG
.0 PGM-QZSRLOG
.0 PGM-QZSRHTTP
.0 PGM-QZSRHTTP
.0
.0 PGM-EASYCOMD
.0 PGM-prngd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
.0 PGM-httpd
Status
DEQW
SIGW
SIGW
SIGW
SIGW
DEQW
DEQW
TIMW
SELW
SELW
DEQW
SELW
TIMW
TIMW
TIMW
TIMW
TIMW
TIMW
TIMW
TIMW
Figure 3-7 Subsystems and jobs pertaining to Zend Core for i5/OS
Access the Setup Tool by running the following command on the i5/OS command line:
GO ZENDCORE/ZCMENU
Figure 3-8 shows the Setup Tool.
Figure 3-8 The Zend Core for IBM i5/OS Setup Tool
The main menu of the Setup Tool contains the following options:
1. Set Zend Core Web Administration Console password
Use this option to set or change the password you use to access the browser-based Zend
Core console.
2. Update via Zend Network menu
Use this option to check for updates to the product. This process requires a Zend Network
user ID and password (which you created when you registered with Zend to download the
product) to access the Zend Network. You can also provide this user ID and password
under this option.
The Update via Zend Network menu also enables you to roll back updates.
3. Run Support Tool
The support tool gathers diagnostic data and bundles it into a GZ file. (The location of the
file is displayed in a message when you run the tool.) You can then send the file to Zend
Support to assist them with problem determination.
5. Service Management menu
The Service Management menu contains options for starting and stopping the Zend
subsystem; starting, restarting, and stopping the Apache HTTP Server instances; and
starting and stopping the i5_COMD service (which is used by the i5 Toolkit for Zend Core).
90. Signoff
This option signs off your 5250 session.
Chapter 3. Administration
27
configure Zend Core: Hand-editing the php.ini file can be error-prone and result in
configuration problems.
To open the Zend Core console, open the following URL in a Web browser, replacing
<system_name> with the host name or IP address of your i5 machine:
http://<system_name>:89/ZendCore
Note: Depending on your systems TCP/IP configuration, the console might not load if you
use the fully qualified host name (host and domain) of the system in the URL. If this occurs,
use the short host name in the URL.
Log in to the console with the password you specified during the installation process. Use the
Zend Core Setup Tool to reset or change the password.
At the top of the page is the menu you use to navigate through the console, as shown in
Figure 3-9. The top row contains tabs for the main console areas. Most items in the top row,
when clicked, display a submenu in the second row that accesses pages in that particular
console area.
Refer to the product documentation for a detailed list of all console features. Briefly, here is an
overview of each tab and the activities that can be performed on those pages:
Control Center
The Control Center area contains information about the product, including the system,
loaded PHP modules, installed and available product updates, and how to get support. Of
particular interest is the benchmark tool, which you can use to simulate hits to a particular
URL and measure response performance.
Configuration
The Configuration tab enables you to change the product configuration, including core
PHP modules, PHP extensions, Zend products, server directives, and the Zend Studio
Server (which integrates server-side functions with the Zend Studio development tool).
Documentation
The Documentation tab provides access to the integrated product documentation for PHP,
Zend Core, and PEAR. There is also a function for searching the documentation.
Many console pages contain controls for saving changes to the configuration and restarting
the server. If changes you have made do not appear to take effect after you have clicked the
link to restart the server, use the Zend Core Setup Tool to restart the servers or the Zend
subsystem.
Click the Logout link to exit the Zend Core console.
28
To access the tool, first start the *ADMIN instance. You can use System i Navigator or the
following i5/OS command:
STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)
After the *ADMIN instance is running, use a Web browser to open the following URL, where
<server_name> is the host name or IP address of your i5 system:
http://<server_name>:2001/HTTPAdmin
When prompted, enter a user profile name with *IOSYSCFG authority and its associated
password.
Note: If your browser uses a pop-up blocker, disable it before using the IBM Web
Administration for i5/OS tool or configure it to access pop-up windows for the site. Some
functions of the tool do not work correctly if pop-ups are blocked.
Figure 3-10 displays the main page of the Web Administration tool.
Tabs at the top of the interface relate to various activities. Selecting certain tabs makes a row
of subtabs appear below the main tabs. If you click Manage HTTP Servers and select
ZENDCORE from the Server list (as shown in Figure 3-11), you can display and change your
IBM HTTP Server for i5/OS server instance.
You can use the Web Administration tool to create other HTTP server instances.
Chapter 3. Administration
29
Tip: Because the ZENDCORE instance forwards all content to the i5/OS PASE Apache
HTTP Server, we recommend that you create another server instance for your static
content (HTML pages, images, and others). Use the ZENDCORE instance only for PHP
files.
Additionally, you can configure the ZENDCORE instance to use secure sockets layer (SSL) or
authentication.
For more information about configuring IBM HTTP Server, see IBM HTTP Server (powered by
Apache): An Integrated Solution for IBM eServer iSeries Servers (SG24-6716-02).
30
In this case, we see three IBM HTTP Server for i5/OS instances. This could be accomplished
in various ways - for example, we could have a single IBM HTTP Server for i5/OS instance
listen on multiple ports. One example of where this may be a desirable option is when you
want to have both HTTP (by default, port 80) and HTTPS (by default, port 443) exposed to the
internet/intranet, but want only one PHP server to handle all these requests.
Figure 3-13 shows how this configuration could be done via the HTTP Server Administration
utility available on port 2001. In this example we see a second port, in this case port 666,
added to our ZENDCORE instance. The default reverse proxy configuration (done by the
Zend Core for i5/OS installation program) is already configured for this instance, meaning that
all requests received on ports 89 and 666 will be sent on to the internal (PASE for i5/OS)
server listening on port 8000.
Chapter 3. Administration
31
32
Figure 3-14 shows a diagram outlining how this scenario might be visualized:
Again, there are many different ways one can create configurations to resemble the
environment shown in Figure 3-14. We saw in Multiple i5/OS Apache instances, one PHP
server on page 30 how we could add a second listening port to the existing ZENDCORE
server configuration. Of course, another option would be to create a second configuration that
can be independently started/stopped, and which listens on a different port.
The easiest way to allow for the creation of a new Apache/PHP instance in PASE for i5/OS is
as follows:
First, create a new version of the php.ini file, which is found in directory
/usr/local/Zend/Core/etc. In our case, we copied php.ini to a new file called php2.ini. Make
any desired modifications to the new file.
Next, create a new version of the httpd.conf file found in directory
/usr/local/Zend/apache2/conf. In our case, we created a copy of httpd.conf called
httpd2.conf in the very same directory.
You must now edit the httpd2.conf file to make it a unique configuration. The following are
some of the lines you should modify:
Example 3-1 Lines to change in httpd2.conf to create new Apache/PHP instance
PidFile logs/httpd2.pid
...
Chapter 3. Administration
33
DocumentRoot "/www/zendcore/htdocs2"
...
<Directory "/www/zendcore/htdocs2">
...
Of course, there are others you may want to modify as well, depending on your configuration
and your goals.
The following line should be added to httpd2.conf to point it at the new php2.ini file:
Example 3-2 Lines to add in httpd2.conf to create new Apache/PHP instance
-k stop
Start
-k start
Restart
-k restart
Important: Whenever issuing these commands make sure you also specify the -f flag
and specify which configuration file to use.
This allows you to independently start or stop any IBM HTTP Server for i5/OS or Apache/PHP
in PASE for i5/OS instance you like.
34
To take advantage of both Apache/PHP servers we could configure our IBM HTTP Server for
i5/OS instance using the IBM Web Administration for i5/OS tool (port 2001) as shown in
Figure 3-16:
Chapter 3. Administration
35
In this case, any incoming requests that specify /garymu on the URL (for example,
http://mysystem.ibm.com/garymu/myfile.php) would be sent to the Apache/PHP instance in
PASE for i5/OS that is listening on port 8001; all other requests (ones that do not specify
/garymu) will be sent to the default server on port 8000. Note that the two configuration
items for /garymu and port 8001 must be above those for / and port 8000, as / is a catch
all. If it is first in the list, no requests will ever flow down the list to test for other matches.
36
/www/zendcore/conf/httpd.conf
If you have made configuration changes to the IBM HTTP Server for i5/OS server instance
(ZENDCORE), you might want to back up its configuration file.
/usr/local/Zend/apache2/conf/*
If you have customized the i5/OS PASE Apache HTTP Server, back up the configuration
files in this directory.
/usr/local/Zend/Core/etc/*
Changes to your Zend Core and PHP configuration are stored in files in this directory.
Chapter 3. Administration
37
38
Chapter 4.
Application development
This chapter discusses the use of PHP as both as a Web and general scripting language. We
discuss the software and concepts commonly used to develop dynamic applications with PHP
and i5/OS data, objects, and programs.
We discuss the following topics in this chapter:
PHP and Web development
PHP as a command-line scripting language
Development tools
39
Web
browser
HTTP Request
Web server
Logic Engine
Data Store
HTTP Response
HTTP/1.1 200 ok
...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>IBM Redbook: Hello World</title>
</head>
40
Put this file in the /www/zendcore/htdocs/ directory using Zend Studio for i5/OS, FTP, or any
other technique that transfers files to i5/OS. You can then access your PHP application via a
Web browser using the IP address of your Zend Core for i5/OS installation, as illustrated in
Figure 4-2.
That is all you need to do in order to make and test your first PHP application.
41
Usually PHP output is buffered, so if you want to disable buffering, you can enter following
command:
<?php while (@ob_end_clean()); ?>
To exit from PHP interactive mode, issue following command:
<?php exit ?>
Figure 4-3 illustrates an example of using PHP in interactive mode.
/QOpenSys/usr/bin/-sh
Interactive mode enabled
> <?php while (@ob_end_clean()); ?>
> <?php for ($i=0;$i<10;$i++) { print "Counting $i\n"; } ?>
Counting 0
Counting 1
Counting 2
Counting 3
Counting 4
Counting 5
Counting 6
Counting 7
Counting 8
Counting 9
===> <?php exit ?>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
42
F11=Truncate/Wrap
F21=CL command entry
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
<?php
for ($i=0;$i<10;$i++)
{
print "Counting $i\n";
}
?>
43
test.php
testzend.php
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
To simply check the syntax of PHP file, you can do it by using the following -l command line
option:
/usr/local/Zend/Core/bin/php -l myfile.php
If no syntax errors are found, the output will be similar to that shown in Figure 4-6.
/QOpenSys/usr/bin/-sh
$
> cd /www/zendcore/htdocs/
$
> /usr/local/Zend/Core/bin/php -l myfile.php
No syntax errors detected in myfile.php
$
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
44
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
<?php
// establish "from" user (optional)
ini_set("sendmail_from","sender@example.org");
// Parameters: recipient, subject, body
mail("me@example.org", "Sent from CL", "CL can call PHP scripts.");
?>
Example 4-4 shows the CL program (compiled as CALLPHP) that invokes the previous PHP
script via PASE for i5/OS.
Example 4-4 CL program: CALLPHP
CALL
PGM(QP2SHELL) +
PARM('/usr/local/zend/Core/bin/php' +
'/www/zendcore/htdocs/emailme.php')
You can invoke the CALLPHP CL program the same way any other program under i5/OS:
CALL CALLPHP
Example 4-5 shows the results of calling the CL program.
Example 4-5 Result from invoking CALLPHP CL program
From: sender@example.org
To: <me@example.org>
Subject: Sent from CL
CL can call PHP scripts.
45
License
Source control
File transfer
Web address
CVS/SVN
FTP
http://www.zend.com
Eclipse
Free
CVS and
SVN(with plugin)
FTP, Web
DAV, SFTP
http://www.eclipse.org
Maguma
Free/commercial
CVS
FTP
http://www.maguma.com
NuSphere PhpED
Commercial
CVS
FTP, SFTP,
Web DAV
http://www.nusphere.com
46
Zend Studio for i5/OS is available for Linux, Mac OS X, and Windows platforms. Zend Studio
for i5/OS is free for customers who downloaded Zend Core for i5/OS, and it is a solid choice for
PHP development. Zend Studio for i5/OS can be downloaded from Zends Web site:
https://www.zend.com/core/oem_registration.php?access_code=IBMi5OSZend
For more information you can visit the following Web address:
http://www.zend.com/products/zend_core/zend_for_i5_os
4.3.2 Eclipse
Eclipse is based on an open and extensible platform written in Java. Although Eclipse was
originally used almost exclusively for Java development, there are a number of good PHP
plug-ins that extend Eclipse to support PHP. Eclipse is available for various platforms including
Windows and Linux. Figure 4-8 shows Eclipse with the PHPeclipse plug-in.
There are commercial and free Eclipse plug-ins to support PHP. One of the most popular free
PHP plug-ins is PHPeclipse, which can be downloaded from:
http://phpeclipse.de/
One of the most popular commercial PHP plug-ins is TruStudio. There is also a free version of
TruStudio. You can find out more about TruStudio at:
http://www.xored.com/trustudio
47
NuSphere PhpED is available only for the Windows platform. An evaluation version can be
downloaded from the following Web site:
http://www.nusphere.com/download.php.ide.htm
48
4.3.4 Maguma
Maguma has different versions of their IDE for PHP. There is a free version (Maguma Open
Studio, shown in Figure 4-10) as well as a commercial version (Maguma Workbench).
Maguma products are available for Windows and Linux. They can be downloaded from:
http://www.maguma.com/en/download.html
49
50
Data Areas
i5_data_area_create
i5_data_area_read
i5_data_area_write
i5_data_area_delete
Data Queue
i5_dtaq_prepare
i5_dtaq_receive
i5_dtaq_send
i5_dtaq_close
Job Log List
i5_jobLog_list
i5_jobLog_list_read
i5_jobLog_list_close
Objects List
i5_objects_list
i5_objects_list_read
i5_ objects_list _close
Spool File
i5_spool_list
i5_spool_list_read
i5_spool_get_data
i5_spool_list_close
User Space
i5_userspace_create
i5_userspace_prepare (new)
i5_userspace_get
i5_userspace_put (new)
In order to access i5/OS resources, we first need to connect to i5/OS. Example 4-6 illustrates
how to connect, which is a requirement when performing most of the i5 PHP API Toolkit calls.
Example 4-6 i5 PHP API Toolkit connection to i5/OS
<HTML>
<?php
/* Connect to server */
$conn = i5_connect("localhost", "PHPUSER", "MYPASSWORD");
if (!$conn)
die("<br>Connection using \"localhost\" with USERID and PASSWORD failed. Error
number =".i5_errno()." msg=".i5_errormsg())."<br>";
else
echo "<br>Connection using \"localhost\" with USERID and PASSWORD OK!<br>\n";
/* Close connection */
i5_close($conn);
?>
</HTML>
Important: Prior to Version 1.6 it was mandatory for both the user ID and password to be
specified in upper case. Starting with V1.6, this restriction was lifted.
When connected (in these examples with user PHPUSER with password MYPASSWORD) we are
able to access i5/OS resources. Example 4-7 on page 52 shows how to perform CL calls by
51
using i5_command. It does that by calling Retrieve Network Attributes command (RTVNETA)
and then displays its output.
Example 4-7 i5_command example
<HTML>
<?php
/* Connect to server */
$conn = i5_connect("localhost", "PHPUSER", "MYPASSWORD");
if (!$conn)
die("<br>Connection using \"localhost\" with USERID and PASSWORD failed. Error
number =".i5_errno()." msg=".i5_errormsg())."<br>";
else
echo "<br>Connection using \"localhost\" with USERID and PASSWORD OK!<br>\n";
/* Call Retrieve Network Attributes command */
$ret = i5_command("rtvneta", array(), array("sysname" => "sysn",
"lclnetid"=>"lclnet"));
if (!$ret) die("<br>rtvneta command failed. errno=".i5_errno()."
msg=".i5_errormsg());
print "<h1><b>Results of \"rtvneta\" command </b></h1><br>" ;
print "System Name : $sysn<br>" ;
print "Local Net ID : $lclnet<br>" ;
/* Close connection */
i5_close($conn);
?>
</HTML>
Example 4-8 shows how to perform an i5/OS program call in PHP. First, we prepare the
program call by using i5_program_prepare, then execute by calling i5_program_call. We end
by calling i5_program_close.
Example 4-8 Program call example
<HTML>
<?php
/* Connect to server */
$conn = i5_connect("localhost", "PHPUSER", "MYPASSWORD");
if (!$conn)
die("<br>Connection using \"localhost\" with USERID and PASSWORD failed. Error
number =".i5_errno()." msg=".i5_errormsg())."<br>";
else
echo "<br>Connection using \"localhost\" with USERID and PASSWORD OK!<br>\n";
$description = array(
array("Name"=>"FIRST", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>"15"),
array("Name"=>"LAST", "IO"=>I5_IN, "Type"=>I5_TYPE_CHAR, "Length"=>"15"),
array("Name"=>"ACCOUNT", "IO"=>I5_OUT, "Type"=>I5_TYPE_CHAR, "Length"=>"15"),
array("Name"=>"AMOUNT", "IO"=>I5_INOUT, "Type"=>I5_TYPE_PACKED,
"Length"=>"5.2")
);
$pgm = i5_program_prepare("PHPLIB/INCRAMT", $description);
if (!$pgm) die("<br>Program prepare error. Error number =".i5_errno()."
msg=".i5_errormsg());
52
$parmIn = array(
"FIRST"=>$_POST["first"],
"LAST"=>$_POST["last"],
"AMOUNT"=>$_POST["amount"]
);
$parmOut = array(
"FIRST"=>"FIRST",
"LAST"=>"LAST",
"ACCOUNT"=>"ACCOUNT",
"AMOUNT"=>"AMOUNT"
);
$ret = i5_program_call($pgm, $parmIn, $parmOut);
if (!$ret) die("<br>Program call error. Error number=".i5_errno()."
msg=".i5_errormsg());
echo "<BR>FIRST :". $FIRST;
echo "<BR>LAST : $LAST";
echo "<BR>AMOUNT : $AMOUNT";
echo "<BR>ACCOUNT : $ACCOUNT";
/* Close program call */
i5_program_close($pgm);
/* Close connection */
i5_close($conn);
?>
</HTML>
Example 4-9 is another example of performing i5 calls. This example shows how to get a
specific system value. In our example we try to get the value of QDATE.
Example 4-9 Get System Value example
<HTML>
<?php
/* Connect to server */
$conn = i5_connect("localhost", "PHPUSER", "MYPASSWORD");
if (!$conn)
die("<br>Connection using \"localhost\" with USERID and PASSWORD failed. Error
number =".i5_errno()." msg=".i5_errormsg())."<br>";
else
echo "<br>Connection using \"localhost\" with USERID and PASSWORD OK!<br>\n";
/* Retrieve System DATE value */
print "Date is: ".i5_get_system_value("QDATE");
/* Close connection */
i5_close($conn);
For more examples and a full reference of available functions, refer to the Zend Core for i5/OS
user guide.
53
Now have a look at the sample HTML document that contains some PHP script as shown in
Example 4-11. After checking for the existence of the file, we load the file using one statement
and then simply loop through and print out the elements read from the XML file, which in this
case are the names of the authors of this book.
Example 4-11 HTML/PHP document that displays the content of the XML file
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Read an XML file</title>
</head>
<body>
<h3>IBM Redbook authors</h3>
<?php
if (file_exists('myXML.xml')) {
$x = simplexml_load_file('myXML.xml');
foreach ($x->person AS $person) {
printf($person->name . ' ' . $person->firstname . '<br>');
}
}
else {
exit('Failed to open myXML.xml.');
}
?>
</body>
</html>
The SimpleXML extension, which was introduced in PHP 5, simplifies common XML tasks.
SimpleXML provides the simplexml_load_file() command, used in our examples to load
XML data into an array. Example 4-12 on page 55 shows how to implement an RSS feed
54
parser using simplexml_load_file(). It will grab blog posts from technorati tagged with the
tag IBM and use RSS to display them.
Example 4-12 RSS implementation using PHP simplexml_load_file()
<HTML>
<?php
$rssurl="http://feeds.technorati.com/feed/posts/tag/ibm";
foreach(simplexml_load_file($rssurl)->channel->item as $i) {
echo '<p><a href="'.$i->link.'">'.$i->title.'</a><br />';
echo $i->description.'</p>';
}
?>
</HTML>
Note: Example 4-12 is just an example and is not ready for production. For example, you
would likely want to implement caching for production use.
The code in Example 4-13 implements a simple XML-RPC service provider with function
hellofunc, which returns the string hello world.
Example 4-13 XML-RPC service provider example
<HTML>
<?php
function hellofunc() {
return "hello world";
}
$xmlrpc = xmlrpc_server_create();
xmlrpc_server_register_method($xmlrpc, 'hellofunc', 'hellofunc');
$r = xmlrpc_server_call_method($xmlrpc, $GLOBALS['HTTP_RAW_POST_DATA'], '');
echo $r;
Chapter 4. Application development
55
xmlrpc_server_destroy($xmlrpc);
?>
</HTML>
For more information regarding the XML-RPC implementation in PHP, visit:
http://www.php.net/manual/en/ref.xmlrpc.php
As an alternative to XML-RPC built-in support in Zend Core, there is also a pure PHP
implementation of XML-RPC. You can download XML-RPC for PHP at:
http://phpxmlrpc.sourceforge.net/
XML-RPC for PHP is written completely in PHP, and it is very easy to implement XML-RPC
services using this library. Note that the code is not officially supported by IBM or Zend.
<?php
function EchoIt($val) {
return $val;
}
$soapsrv = new SoapServer(null, array(location=>"http://xx.xx.xx.xx/soap.php",
'uri'=>"http://xx.xx.xx.xx/"));
$soapsrv->addFunction("EchoIt");
$soapsrv->handle();
?>
Example 4-14 demonstrates a SOAP service that returns the value passed in to the service.
For more information regarding SOAP implementation in PHP, we recommend:
http://www.php.net/manual/en/ref.soap.php
Example 4-15 shows how to create a Web service for an existing RPG program.
Example 4-15 Creating Web service for an existing RPG program
<?php
/*
This service invokes a RPG program with two parameters
*/
class i5_program_service {
private $conn = false;
56
function __construct() {
$this->conn = i5_connect('127.0.0.1', 'user', 'password'/*, $connection_pa
rameters*/);
if (!is_resource($this->conn)) {
throw new SoapFault('i5_program_service', 'Connection to i5 server fa
iled, use i5_errormsg() to get the failure reason');
}
}
public function service_for_i5_program($var_0, $var_1) {
$description = Array (
array ('Name' => 'code', 'IO' => I5_INOUT, 'Type' => I5_TYPE_CHAR, 'Length
' => '10'),
array ('Name' => 'name', 'IO' => I5_INOUT, 'Type' => I5_TYPE_CHAR, 'Length
' => '10'));
$prog = i5_program_prepare('eacdemo/teststp2', $description, $this->conn);
if (is_resource($prog)) {
/* Execute Program */
$params = array (
'code' => $var_0, 'name' => $var_1);
$retvals = array(
'code' => 'ret_val_1', 'name' => 'ret_val_2');
$ret = i5_program_call($prog, $params, $retvals) ;
if ($ret === true) {
$ret = array($ret_val_1, $ret_val_2);
return $ret;
}
else {
throw new SoapFault('i5_program_service', 'Failed to call the prog
ram, use i5_errormsg() to get the failure reason');
}
if (!i5_program_close ($prog) ) {
throw new SoapFault('i5_program_service', 'Failed to free program
resource handle, use i5_errormsg() to get the failure reason');
}
}
else {
throw new SoapFault('i5_program_service', 'Program prepare failed, use
i5_errormsg() to get the failure reason');
}
57
}
function __destruct() {
if (!i5_close($this->conn)) {
// Failed to disconnect from i5 server, use i5_errormsg() to get the f
ailure reason
}
}
}
ini_set('soap.wsdl_cache_enabled', '0');
$server = new SoapServer('wsdl_service.wsdl');
$server->setClass('i5_program_service');
$server->handle();
?>
58
Chapter 5.
Database access
This chapter provides details on ways to access data stored on i5/OS from PHP applications.
We focus on data stored in DB2 for i5/OS and briefly discuss MySQL.
59
5.1 DB2
IBM DB2 is an advanced relational database management system that adheres to open
standards and is capable of managing both large-scale data and high-speed transactions.
DB2 data server provides a high-performance and robust environment for all types and sizes
of databases and applications that run on it.
DB2 data server offers database solutions that run on all platforms, including AIX, Sun,
HP-UX, Linux, Windows, i5/OS, and z/OS on both 32-bit and 64-bit environments. The DB2
family is a consistent set of relational database management systems (RDBMS) that utilizes
shared technologies and a common application programming interface.
60
IBM_DB2
A good source of documentation about these APIs provided by the ibm_db2 extension is
available at:
http://www.zend.com/manual/ref.ibm-db2.php
Documentation about the ibm_db2 extension for the Linux, UNIX, and Windows platforms
can be found at the following address. Note that even though the information is not geared
toward i5/OS, much of it is accurate and applicable:
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.ud
b.apdv.php.doc/doc/t0023484.htm
Also, see the IBM Redbook Developing PHP Applications for IBM Data Servers, SG24-7218,
for excellent information about the ibm_db2 extension, including much valuable technical
detail that will not be repeated here. The book is available at:
http://www.redbooks.ibm.com/abstracts/sg247218.html?Open
The ibm_db2 extension of PHP provides the interface to connect from PHP to IBM DB2,
Cloudscape, and Apache Derby databases. This extension provides mechanisms for
application developers to issue SQL queries, work with large objects, call stored procedures,
use persistent connections, and use prepared SQL statements. It also works on PHP
releases below Version 5. Unlike PDO_ODBC, ibm_db2 is based on traditional procedural
programming and performs better when compared to Unified ODBC functions. ibm_db2
provides built-in functions for getting details about the DB2 database server and client by
querying system tables, which provide lots of information about the DB2 database
management system.
Tip: If you understand the C programming language and at any time want to see how the
driver actually works, you can view the source code at the following URL:
http://viewcvs.php.net/viewvc.cgi/pecl/ibm_db2/
i5/OS considerations
If you create a connection to DB2 for i5/OS (with db2_connect) without specifying a user ID or
password, the database is accessed within the same process that the PHP script is
executing. Often (but not always) this is one of several jobs in the ZEND subsystem that
looks something like the jobs shown in Example 5-1.
Example 5-1 Jobs under which PHP scripts execute
3.4
Elapsed time:
00:00:00
12/15/06
Active jobs:
311
5=Work with
6=Release
13=Disconnect ...
Type
BCI
BCI
BCI
BCI
CPU %
.0
.0
.0
.0
RCHXXXXX
15:20:03
7=Display message
Function
PGM-httpd
PGM-httpd
PGM-httpd
PGM-httpd
Status
TIMW
TIMW
TIMW
TIMW
More...
Parameters or command
===>
Chapter 5. Database access
61
F3=Exit
F5=Refresh
F11=Display elapsed data
F7=Find
F12=Cancel
F10=Restart statistics
F23=More options
F24=More keys
If you create the connection by passing in a user ID and password, then so-called server
mode is used. In this case, the database is accessed through a QSQSRVR job.
See 7.1.4, User profiles on page 89 for more details on user profiles and PHP on i5/OS.
Attention: Column names in the SQL statement must be in upper-case unless you are
using the option of DB2_ATTR_CASE to DB2_CASE_LOWER in the db2_connect()
function.
List of APIs
The following is the list of APIs supported by the ibm_db2 extension. They are placed into
common groups for convenience.
Table 5-1 ibm_db2 APIs
API
Description
Server/connection APIs
db2_bind_param
db2_client_info
db2_close
db2_connect
db2_cursor_type
db2_exec
db2_execute
db2_prepare
db2_pconnect
db2_server_info
db2_statistics
Returns a result set listing the index and statistics for a table.
Results
db2_free_result
db2_next_result
db2_result
Commit/rollback
62
db2_autocommit
db2_commit
Commits a transaction.
db2_rollback
API
Description
Fetch
db2_fetch_array
db2_fetch_assoc
db2_fetch_both
db2_fetch_object
db2_fetch_row
Field information
db2_field_display_size
db2_field_name
db2_field_num
db2_field_precision
db2_field_scale
db2_field_type
db2_field_width
Key information
db2_foreign_keys
db2_primary_keys
Statement
db2_free_stmt
Errors
db2_conn_error
db2_conn_errormsg
db2_stmt_error
db2_stmt_errormsg
63
API
Description
Column/procedure
db2_column_privileges
db2_columns
db2_procedure_columns
db2_procedures
db2_special_columns
Returns a result set listing the unique row identifier columns for
a table.
Table information
db2_num_fields
db2_num_rows
db2_table_privileges
db2_tables
i5/OS-specific functionality
There are a number of configurable attributes that can be set on the db2_connect() call. The
entire list is contained in Table 5-2. Note that these attributes are specific to i5/OS, as you can
tell from the i5_ prefix on the attribute keys.
An example of how you would pass in these attributes is shown in the following code snippet:
$options = array("i5_lib"=>"mylibrary", "i5_commit"=>DB2_I5_TXN_READ_UNCOMMITTED);
$i5 = db2_connect($i5localhost, $i5user, $i5password, $options);
Table 5-2 Configurable attributes on db2_connect() call
Key
Value
i5_lib
A character value that indicates the default library that will be used for
resolving unqualified file references. This is not valid if the connection is using
system naming mode.
Note: if this attribute is not passed in you must fully qualify your table name
with the DB2 for i5/OS schema (library): for example, myschema.mytable.
i5_naming
64
Key
Value
i5_dbcs_alloc
i5_commit
i5_date_fmt
65
Key
Value
i5_date_sep
i5_time_fmt
i5_time_sep
i5_decimal_sep
66
Key
Value
i5_query_optimize
i5_fetch_only
Code examples
Some simple code examples follow. These are snippets, and not full programs.
Example 5-2 shows how to create a prepared statement, bind a parameter, execute it, and
then iterate through the result set.
Example 5-2 Use of prepared statement
...
$options = array("i5_lib"=>"QIWS");
$i5 = db2_connect($db, $user, $password, $options);
if (!$i5) :
die ("Problems connecting to the database.");
endif;
/* Construct the SQL statement, using CDTLMT as the search substring */
$sql = "select * from QCUSTCDT where CDTLMT > ?";
/* Prepare, bind and execute the DB2 SQL statement */
$stmt= db2_prepare($i5, $sql);
$lower_limit = 1000;
db2_bind_param($stmt, 1, "lower_limit", DB2_PARAM_IN);
db2_execute($stmt);
...
/* Execute the statement again with a new input parameter */
$upper_limit = 99999;
db2_bind_param($stmt, 1, "upper_limit", DB2_PARAM_IN);
db2_execute($stmt);
Example 5-3 on page 68 shows how to use the db2_procedures API to get a list of stored
procedures available in i5/OS.
Chapter 5. Database access
67
...
$procName = '%';
$schemaName = '%';
$procs = db2_procedures($conn, '', $schemaName, $procName);
if (!$procs){
print ('Error in db2_procedures() call');
} else {
print '<h1>Procedures found in schema ' . $schemaName . ' on System i</h1>';
print '<h2>Using db2_procedures and db2_fetch_array</h2>';
print '<br><table border=1 cellpadding=5 cellspacing=5>';
print '<tr><td
align=center>procedure_cat<td>procedure_schem<td>procedure_name<td>num_input_param
s<td>num_output_params<td>num_result_sets<td>remarks</td></tr>';
while ($row = db2_fetch_array($procs)) {
if (!$row=="") {
$procedure_cat = $row[0];
$procedure_schem = $row[1];
$procedure_name = $row[2];
$num_input_params = $row[3];
$num_output_params = $row[4];
$num_result_sets = $row[5];
$remarks = $row[6];
print '<tr><td align=center>' . $procedure_cat .'<td>'.$procedure_schem.
'<td>'.$procedure_name.'<td>'.$num_input_params.'<td>'.$num_output_params.'<td>'.
$num_result_sets.'<td>'.$remarks.'</td></tr>';
}
}
print '</table><br>';
}
...
PDO_ODBC
PDO (PHP Data Objects) is an object-oriented, standards-based data access method in PHP,
where you can use the same methodology to query the database and fetch data from the
supported databases. The PDO_ODBC extension is the implementation of PDO
specification. When compiled with DB2 libraries, you can use it to access DB2, Cloudscape,
and Apache Derby databases. This extension provides a mechanism to connect to both local
cataloged and non-cataloged databases. For a local cataloged database, PDO_ODBC
obtains the database server details from the client machine. For a non-local cataloged
database, the full details of the remote database are specified in the connection URL.
PDO_ODBC also provides access to advanced features of DB2, such as persistent
connections, prepared SQL statements, large objects, and stored procedures. It provides
better performance compared to Unified ODBC functions.
As mentioned previously, PDO_ODBC is not currently supported with DB2 for i5/OS.
Unified ODBC
Unified ODBC was the only method for PHP to talk with DB2 before the ibm_db2 extension
was released. As with the ibm_db2 extension, Unified ODBC interacts with DB2 using native
CLI calls. It uses the same PHP methods to interact with different databases even if the
underlying mechanism is different; thus, ODBC offers greater database independence than
68
extensions designed for a specific DBMS. However, this API cannot be used to call stored
procedures in DB2. In addition, you will achieve better performance by using the ibm_db2
extensions, because they are optimized for DB2 access.
Example 5-4 illustrates a sample of Unified ODBC usage.
Example 5-4 Unified ODBC and DB2 for i5/OS
<HTML>
<?php
# connect to rdb directory entry called 'mysystem' ...
# ...using kost as username and newpass as password
$dbh=odbc_connect('mysystem','kost','newpass');
# check if connected
if (!$dbh) {
die ('Connection Failed: ' . $dbh);
}
# execute the query
$sql="SELECT Host,User FROM schema.user";
$res=odbc_exec($dbh,$sql);
if (!$res) {
die ("Error in SQL: $sql");
}
# output the results
while (odbc_fetch_row($res))
{
print odbc_result($res,"Host").':';
print odbc_result($res,"User").'<br />';
}
# close the connection
odbc_close($dbh);
?>
</HTML>
To read more about the Unified ODBC extension and its features, refer to:
http://www.php.net/manual/en/ref.uodbc.php
69
For an example of using a prepared statement see Example 5-2 on page 67.
Persistent connections
Persistent connections can dramatically improve overall performance, but must be used with
caution.
The main advantage of using a persistent connection is that it avoids much of the initialization
and teardown normally associated with getting a connection to the database. When
db2_close() is called against a persistent connection, the call always returns TRUE, but the
underlying DB2 client connection remains open and waiting to serve the next matching
db2_pconnect() request.
One main area of concern with persistent connections is in the area of commitment control.
You should use persistent connections only when you leave automatic commitment control
(autocommit) turned on. Mixing managed commitment control and persistent connections
can result in unknown transaction states if errors occur. Consider the following scenario:
1. Request A gets a persistent connection, turns off autocommit, and performs various
database update (insert/update/delete) operations.
2. Request A encounters an error, and neglects to either commit or roll back the transaction.
The db2_close() operation is called. Note that not all desired updates were performed.
3. Request B requests a persistent connection, and is given the same one just used by
Request A. It performs several database updates, and commits its changes.
4. The incomplete database changes performed by Request A were also committed when
Request B committed its changes. Thus, we now have a database with inconsistent and
incomplete transactions.
70
5.1.3 Troubleshooting
We know of no tracing functionality built in to the ibm_db2 driver. A few of the places you
should look when problems are occurring include:
i5/OS job logs, message queues, and so forth
PHP log files (php_error_log is probably the best place to look)
Application-generated messages (either sent to the browser or put in a separate log file)
An excellent source of debug and troubleshooting information for DB2 for i5/OS not
specifically related to PHP can be found in the IBM Redbook SQL Performance Diagnosis on
IBM DB2 Universal Database for iSeries, SG24-6654. It can be found at:
http://www.redbooks.ibm.com/Redbooks.nsf/RedbookAbstracts/sg246654.html?Open
5.2 MySQL
MySQL is a common Open Source SQL database management system. It is developed and
distributed by MySQL AB (http://www.mysql.com), a company that builds its business by
providing services around MySQL.
MySQL first was developed for UNIX and Linux applications. It became popular when Internet
service providers (ISP) discovered that MySQL could be offered free of charge to their
Internet customers, and was able to provide all the storage and retrieval functionality a
dynamic Web application needs. It was also advantageous that ISPs mostly use Linux or
UNIX together with Apache as their favorite Web server environment. However, MySQL is in
use as an integrated database in many applications on almost every operating system.
mysql home
directory
bin
data
mysql
itsodb
...
docs
include
installed
databases
lib
man
scripts
...
71
72
4. When you have the .tar file, transfer it to the /usr/local directory on i5/OS (probably using
FTP).
5. Log on to a 5250 session as user QSECOFR.
6. Go to the PASE for i5/OS environment by issuing the following command:
call qp2term
7. Change to directory /usr/local by issuing the command:
cd /usr/local
8. Untar the file with command tar xvf mysql-max-5.0.24a-aix5.2-powerpc-64bit.tar as
illustrated in Figure 5-2.
/QOpenSys/usr/bin/-sh
$
> cd /usr/local
$
> ls
Zend
mysql-max-5.0.24a-aix5.2-powerpc-64bit.tar
$
> tar xvf mysql-max-5.0.24a-aix5.2-powerpc-64bit.tar
x mysql-max-5.0.24a-aix5.2-powerpc-64bit
x mysql-max-5.0.24a-aix5.2-powerpc-64bit/bin
x mysql-max-5.0.24a-aix5.2-powerpc-64bit/bin/comp_err, 1379704 bytes, 2695
me
dia blocks.
x mysql-max-5.0.24a-aix5.2-powerpc-64bit/bin/replace, 1377369 bytes, 2691
med
ia blocks.
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
9. Create a symbolic link called mysql to the new directory (which in our case is called
mysql-max-5.0.24a-aix5.2-powerpc-64bit) for easier directory navigation with the
following command:
ln -s mysql-max-5.0.24a-aix5.2-powerpc-64bit mysql
10.Create the MySQL system table by issuing the following command:
scripts/mysql_install_db --user=mysql
11.Now you can start the MySQL server with the following command (as shown in Figure 5-3
on page 74):
bin/mysqld_safe --user=mysql &
73
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
12.To verify that installation was successful, issue the following command:
bin/mysqlcheck -u root mysql
You should get output similar to that shown in Figure 5-4.
> bin/mysqlcheck -u root mysql
mysql.columns_priv
mysql.db
mysql.func
mysql.help_category
mysql.help_keyword
mysql.help_relation
mysql.help_topic
mysql.host
mysql.proc
mysql.procs_priv
OK
OK
OK
OK
OK
OK
OK
OK
OK
OK
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
If you get error messages similar to those shown in Figure 5-5 it probably means that the
MySQL server is not running.
> bin/mysqlcheck -u root mysql
bin/mysqlcheck: Got error: 2002: Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2) when trying to connect
$
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
74
F11=Truncate/Wrap
F21=CL command entry
13.In order to utilize MySQL with PHP in Zend Core you must enable the MySQL Extensions
in the Zend Core control center. You can do that also by uncommenting (removing the #
character) from the following lines in /usr/local/Zend/Core/etc/php.ini file:
extension=mysql.so
extension=mysqli.so
14.To stop the MySQL server, run the following command (from the /usr/local/mysql
directory):
bin/mysqladmin -u root shutdown
Upon successful shutdown, there will be no messages.
15.For better security we recommend that you set a password for the root MySQL user. You
can do that by typing the following command (from the /usr/local/mysql directory):
bin/mysqladmin -u root password newpass
This command will change the password for user root to newpass.
Note: After you set a password for the root MySQL user, you must specify the password
while working with the database (on behalf of user root). For example, to shut down the
server, specify following command:
bin/mysqladmin -u root -pnewpass shutdown
16.We recommend that you read the UNIX Post-Installation Procedures in the MySQL 5.0
Reference Manual at the following address:
http://dev.mysql.com/doc/refman/5.0/en/unix-post-installation.html
MySQL/MySQLi
The mysql and mysqli extensions of PHP provide interfaces to connect from PHP to MySQL
databases. These extensions provide mechanisms for application developers to issue SQL
queries, work with large objects and use persistent connections. These extensions also work
with PHP releases below Version 5. Unlike PDO_ODBC, mysql and mysqli are based on
traditional procedural programming and perform better compared to Unified ODBC. The main
difference between mysql and mysqli is that mysqli is a more advanced (improved)
extension of mysql and supports MySQL functions provided by MySQL 4.1 and above.
To read more about the mysql extension and its features, refer to the following Web site:
Chapter 5. Database access
75
http://www.php.net/manual/en/ref.mysql.php
Example 5-5 shows an example of mysql extension usage.
Example 5-5 mysql extension example
<HTML>
<?php
# connect to MySQL DBMS using root as username and kost as password
$dbh = mysql_connect('localhost', 'root', 'kost');
# check if connected
if (!$dbh) {
die('mysql connect failed: '.mysql_error());
}
# select database and do the query
mysql_select_db("mysql");
$sql='select Host,User from user';
$res = mysql_query($sql);
if (!$res) {
die('Error: $sql: '.mysql_error());
}
# output the query results
while ($r = mysql_fetch_assoc($res)) {
print $r['Host'].':';
print $r['User'].'<br />';
}
# free the query resources
mysql_free_result($res);
# close connection to MYSQL DBMS
mysql_close($dbh);
?>
</HTML>
An example of mysqli usage is illustrated in Example 5-6. To read more about the mysqli
extension and its features, refer to:
http://www.php.net/manual/en/ref.mysqli.php
Example 5-6 Procedural syntax of mysqli extension
<HTML>
<?php
# connect to MySQL system database called 'mysql' ...
# ...using root as username and kost as password
$dbh = mysqli_connect('localhost', 'root', 'kost', 'mysql');
# check if connected
if (!$dbh) {
die('mysqli connect failed: '.mysqli_connect_error());
}
76
PDO_MYSQL
PDO (PHP Data Objects) is an object-oriented, standards-based data access method in PHP,
where you can use the same methodology to query the database and fetch data from the
supported databases. The PDO_ODBC extension is the implementation of PDO
specification. It provides better performance compared to Unified ODBC functions.
Unified ODBC
Unified ODBC uses the same PHP methods to interact with different databases even if the
underlying mechanism is different. It therefore provides a level of database independence to
your code, at the price of less functionality and reduced performance.
The free source code for all of the extensions is available for download at the PECL Web site:
http://pecl.php.net/
77
embedded in PHP code. However, you can copy individual SQL statements into the DB2 MTK
Translator utility to ease conversion of complex MySQL SQL statements.
Another helpful resource is the DB2 for i5/OS - Porting Information Web site at:
http://www.ibm.com/servers/enable/site/db2/porting.html
Find a document highlighting some of the differences between DB2 for i5/OS and MySQL at:
http://www.ibm.com/developerworks/systems/library/es-path2php/
78
Chapter 6.
79
6.1 Overview
The Java Bridge support makes it possible to call Java programs from within PHP. This
enables you to directly access existing Java applications you might have written already, or
simply i5/OS resources (data queues, printers, and so on) by interfacing with the IBM Toolbox
for Java. By doing so you avoid the development time and code overhead of using a
technology such as Web services to expose or consume existing functionality.
More information about the Java Bridge support is available at:
http://www.zend.com/products/zend_platform/in_depth/php_java_integration
Additional information about the IBM Toolbox for Java can be found at:
http://www.ibm.com/eserver/iseries/toolbox/
80
From this screen we can see that our classpath change in fact worked.
We can stop and restart the Java Bridge support from this screen. You can also perform these
actions from an i5/OS PASE terminal with the following commands (first change into the
correct directory with cd /usr/local/Zend/Platform).
Start
Stop
Restart
Status
bin/javamw.rc
bin/javamw.rc
bin/javamw.rc
bin/javamw.rc
start
stop
restart
status
81
<html>
<head><title>Java System Properties</title></head>
<?php
// Get java.lang.System instance
$system = new Java("java.lang.System");
// Get the properties.
// In PHP this will be put into an array of key-value pairs
$properties = $system->getProperties();
// Iterate through properties and write out to screen
foreach($properties as $key=>$value) {
echo "<br>";
echo $key . " : " . $value;
}
?>
</html>
The output from running this PHP program looks similar to Figure 6-2.
82
<html>
<head><title>Message Queue Test</title></head>
<?php
// Get an AS400 connection object
$as400 = new Java('com.ibm.as400.access.AS400', 'localhost', 'myuserid',
'mypassword');
// Create the MessageQueue object
$mq = new Java('com.ibm.as400.access.MessageQueue', $as400,
'/QSYS.LIB/QUSRSYS.LIB/GARYMU.MSGQ');
// Get the number of messages in the queue and print it out
$numMessages = $mq->getLength();
echo '<br>Number of messages: ' . $numMessages ;
// If we have messages, print each; otherwise indicate no messages exist
if (0 < $numMessages) {
$messages = $mq->getMessages(-1, 0);
foreach($messages as $value) {
echo '<br>Message = ' . $value;
}
} else {
echo '<br>No messages in queue.';
}
// Disconnect all services
$as400->disconnectAllServices();
?>
</html>
The output from this program looks similar to Figure 6-3 on page 84 (if there are messages in
the queue).
83
Figure 6-3 Output from running Java Toolbox message queue program
<html>
<head><title>Data Queue Test</title></head>
<?php
// Get an AS400 connection object
$as400 = new Java('com.ibm.as400.access.AS400', 'localhost', 'myuserid',
'mypassword');
// Get a data queue object
$dq = new Java('com.ibm.as400.access.DataQueue', $as400,
"/QSYS.LIB/GARYMU.LIB/GARYDATAQ.DTAQ");
// Create a data queue object in i5/OS if it doesn't exist; otherwise clear its
contents
if (!$dq->exists()) {
$dq->create();
} else {
$dq->clear();
}
// Write a string to the data queue containing the current time
$dq->write("Current date and time: " . date("F j, Y, g:i a"));
// Peek the data - this does not remove the entry from the data queue
$entry = $dq->peek();
$data = $entry->getString();
// Write out the data to the browser
84
Figure 6-4 Output from running Java Toolbox data queue program
85
Stack trace:
#0 /www/zendcore/htdocs/garymu/JavaBridgeDataQueuePost.php(9): *No
Class!*->java('com.ibm.as400.a...', Object(com.ibm.as400.access.AS400))
#1 {main}
thrown in /www/zendcore/htdocs/garymu/JavaBridgeDataQueuePost.php on line 9
86
Chapter 7.
Security
This chapter provides details about unique security considerations for PHP on i5/OS.
87
Configuration files
The main PHP configuration file (php.ini) is located in directory /usr/local/Zend/Core/etc. This
file (and all others in this directory) can be edited by any user. You should probably modify the
access attributes so that only specific administrators can change the files.
The same is true for the internal Apache server: Its configuration file (httpd.conf) is located in
the directory /usr/local/Zend/apache2/conf.
The external Apache server configuration file (httpd.conf) is located in the /www/zendcore/conf
directory. By default, *PUBLIC does not have write authority to this file.
Chapter 7. Security
89
90
Chapter 8.
Performance
This chapter provides details about performance tuning of PHP on i5/OS.
Note: This section is far from comprehensive. Much more information will become
available over the upcoming months and years as Zend for i5/OS gains wide acceptance in
the marketplace.
91
8.1.1 Hardware
Of course, if your System i is underpowered, PHP will not perform well. Currently, the IBM
Systems Workload Estimator (WLE, at http://www-912.ibm.com/estimator/index.html)
does not provide support for estimating PHP workloads on i5/OS.
However, the Estimator does provide support for modeling WebSphere workloads. We
recommend using a non-EJB workload as a rough guideline for PHP. Figure 8-1 shows
recommended parameters.
Figure 8-1 Recommended parameters for estimating PHP workload using Workload Estimator
92
Important: Using Workload Estimator in this way to model PHP behavior is very rough,
and should only be used as a starting point for sizing. Your actual results might vary
significantly.
8.1.2 i5/OS
It is very important that the core i5/OS operating system be well tuned. There is a wealth of
information about how to do this. For many valuable links, visit:
http://www.ibm.com/servers/eserver/support/iseries/planning/perfcapacity.html
A Redpaper is available that provides a nice overview of the main performance analysis tools
that are available. It is called IBM eSeries iSeries Performance Management Tools,
REDP-4026, and is available at:
http://www.redbooks.ibm.com/abstracts/redp4026.html?Open
8.1.5 Apache
Good information about tuning Apache for maximum performance on i5/OS is available in
IBM HTTP Server (powered by Apache): An Integrated Solution for IBM eSeries iSeries
Servers, SG24-6716, which can be found at:
http://www.redbooks.ibm.com/abstracts/sg246716.html?Open
Chapter 8. Performance
93
94
Chapter 9.
Troubleshooting
This section focuses on identifying and resolving problems in the PHP environment.
An inherent difficulty that arises with Web technologies in general is that they are usually
comprised of multiple components. This affects the process of troubleshooting a Web
environment because it can be hard to determine in which component the problem is
occurring. Figure 9-1 shows several places where failure can occur.
Note: Although it might seem that the Web environment is fragile, it is important to note
that if you have correctly configured and tested your environment, the vast majority of
failures you see occur as a result of application errors, not because of the environment
componentry.
95
When troubleshooting a multiple-component topology, you first need to narrow down the
problem to a particular component. Determine how far a request gets in the topology, and you
have identified the best place to start looking for a problem. This can be tricky considering
that most symptoms of a problem first surface in the browser. Work your way through the
topology from the beginning. Construct a series of questions and related tests that help you
determine whether a particular component is working correctly.
Here are examples of the types of questions to ask to locate a problem:
Can you view similar content in the browser?
Can you ping the server?
Can you access static Web pages from your HTTP server?
Can you access other dynamic pages from your HTTP server?
Can you access other PHP applications from the same Zend Core installation?
If your application accesses external resources, such as databases and files, can you
manually access them?
96
Chapter 9. Troubleshooting
97
Specify option 8 (Display jobs) to show what jobs are using a particular port. Figure 9-2
shows that the I5_COMD job uses port 6077. Note that the default port is 6078; this can be
changed using the ZCMENU options.
You should also check the IBM HTTP Server for i5/OS configuration to ensure that you are
using the correct URL, including port number, to invoke the application. URLs are typically
based on a Web pages location, relative to the Web servers document root directory
structure; however, aliases and redirections can be configured to mask the document root
structure. You also might check the systems TCP/IP configuration with the Configure TCP/IP
(CFGTCP) command to ensure that the host name you are using in the URL is correct.
Another item to check in the configuration of the Web servers is that the IBM HTTP Server for
i5/OS server forwards requests to the PASE Apache HTTP Server using the appropriate port
number, which defaults to 8000.
Check the logs for the Web servers for any error messages. Because both Web servers are
based on the Apache HTTP Server, their logging functions are similar. By default, the Web
servers gather information into two logs: the error log and the access log. The value of the error
log is obvious. The access log records server resources being accessed. You can use the
access logs for both Web servers to ensure that a request arrived at both servers. If the request
is logged in the IBM HTTP Server for i5/OS access log and not in the PASE Apache HTTP
Server access log, then you know the problem must lie in the linkage between the two servers.
98
You can also configure the servers to use custom logs, based on whatever criteria you decide.
For more information about this and the Web server logs in general, see the product
documentation:
IBM HTTP Server for i5/OS
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzaie/rzaieconfiglo
gs.htm
Apache HTTP Server
http://httpd.apache.org/docs/2.0/logs.html
Chapter 9. Troubleshooting
99
The console contains several settings. These are important settings you should know:
display_errors: If set to On, error messages are written to the browser. This feature can be
very helpful in determining when an error is occurring during application processing.
display_startup_errors: By default, startup errors are suppressed. If you have problems
starting the server, change this setting to On.
error_log: Specifies the path and name of the error log file.
error_reporting: Sets the level of error reporting. By default, this property is set to the
highest level (ALL). For production-level systems, the value can be reduced.
log_errors_max_len: Sets the maximum size of the log files. When log files reach this size,
a new file is started.
For more information about PHP logs, see Error Handling and Logging Functions in the
PHP documentation:
http://www.php.net/manual/en/ref.errorfunc.php
If your application uses a particular PHP extension, use the console to check that the
extension is enabled. Click the Configuration tab and then the Extensions tab. Extensions
are listed with corresponding icons that communicate their status. A red exclamation mark, as
shown in Figure 9-5, denotes an error with an extension.
If you suspect that requests from the PASE Apache HTTP Server is not reaching Zend Core,
check the Zend directives in the Apache configuration file, httpd.conf, which is located in the
/usr/local/Zend/apache2/conf directory. The Zend directives are at the end of the file.
Periodically back up this file so you have something to use for comparison.
100
and the DSPAUT (Display Authority) command for objects in the Integrated File System (IFS).
The user profile you use for access (either one you specify or the default, NOBODY) usually
needs at least read (*R) authority.
Figure 9-6 shows the authorities for the PHPTRB library. Note that *PUBLIC user authority is
set to *EXCLUDE, and only the user profile that owns the object can change it. In this case,
you should grant *READ authority to the NOBODY user profile (or a non-default profile your
application uses).
The Grant Object Authority (GRTOBJAUT) command can be used to authorize a user profile
to a particular resource.
Chapter 9. Troubleshooting
101
In Figure 9-7, the PHPUSER user profile is used for the database connections, which is
specified by the QSQSRVR user data. These files (QPJOBLOG) contain messages about
accessing the database.
The history log on production systems might be extremely large. When displaying the history
log, you want to display only the messages for a certain time period. Type the Display Log
(DSPLOG) command and press F4 to enter the time period.
102
Chapter 9. Troubleshooting
103
104
10
Chapter 10.
Globalization
This chapter provides details about the support of non-English languages when running PHP
on i5/OS, which is somewhat complex because PHP currently does not support Unicode. We
show concrete examples of how to enable the Cyrillic alphabet, which is interesting in that it
forces the use of atypical code pages/CCSIDs.
We also discuss what types of non-English character data can be queried from DB2 and used
within PHP.
105
10.1 Overview
This section provides a brief overview of existing internationalization support in PHP 5, and
then a description of each layer involved in providing PHP support in i5/OS and how it
influences internationalization support.
i5/OS
Traditionally, i5/OS has always been an EBCDIC-based machine. The vast majority of
applications running on the box use data that is encoded in an EBCDIC-coded character set
ID (CCSID). For a list of i5/OS-supported CCSIDs, visit:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/nls/rbagscc
sidcdepgscharsets.htm)
Many CCSID transformations can and do occur automatically when running applications
under i5/OS. For example, Java is a Unicode-based language. When EBCDIC data is
extracted from DB2 for i5/OS via the JDBC driver, an automatic transformation occurs from
EBCDIC to Unicode. Many similar such transformations occur, often unbeknownst to the
application developer and user.
PHP runs in the IBM i5/OS Portable Application Solutions Environment (PASE) under i5/OS.
When an i5/OS PASE shell is created from i5/OS, many globalization-related configuration
settings of the i5/OS job are passed to the i5/OS PASE environment.
For a full discussion of i5/OS globalization see:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/nls/rbagsgl
obalmain.htm
106
i5/OS PASE
The i5/OS PASE environment is an integrated runtime that makes it easy to run AIX
applications from i5/OS. The following is a simplified view of how i5/OS PASE interacts with
i5/OS and the System i hardware:
i5/OS Applications
i5/OS PASE
Applications
i5/OS
PASE
Shared
Libraries
i5/OS
syscall bdy.
SLIC Kernel
loader
Power PC
Power PC AS
Server IOPs
Hardware
Device IOPs
RAID
PHP is implemented as an i5/OS PASE application that is initiated from i5/OS. Because of
this, the i5/OS PASE environment that PHP runs in inherits its globalization from the i5/OS job
that started it. For example, first issue the following command from i5/OS:
CHGJOB LANGID(RUS) CNTRYID(RU) CCSID(1025)
This changes the jobs language and country IDs, and the jobs CCSID to 1025 (which is the
primary EBCDIC CCSID for Cyrillic).
Then start an i5/OS PASE terminal:
CALL PGM(QP2TERM)
As shown in Example 10-1, several globalization environment variables have been set
automatically (in bold).
Example 10-1 Environment variables in new i5/OS PASE environment
$
> env
_=/QOpenSys/usr/bin/env
LANG=ru_RU
PASE_LANG=ru_RU
QIBM_PASE_DESCRIPTOR_STDIO=T
PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
ROWS=17
107
QIBM_DESCRIPTOR_STDIN=CRLN=Y
COLUMNS=129
PASE_PATH=/QOpenSys/usr/bin:/usr/ccs/bin:/QOpenSys/usr/bin/X11:/usr/sbin:.:/usr/bin
LC__FASTMSG=true
LOGNAME=QSECOFR
LOCPATH=/usr/lib/nls/loc
PASE_LC__FASTMSG=true
QIBM_IFS_OPEN_MAX=66000
QIBM_USE_DESCRIPTOR_STDIO=I
QIBM_PASE_CCSID=915
PASE_SHELL=/QOpenSys/usr/bin/sh
SHELL=/QOpenSys/usr/bin/sh
PASE_LOCPATH=/usr/lib/nls/loc
HOME=/home/QSECOFR
PASE_TZ=UTC0
PASE_NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg
/ru_RU/%N:/usr/lib/nls/msg/ru_RU/%N.cat
PWD=/
TZ=UTC0
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat:/usr/lib/nls/msg/ru_RU/%
N:/usr/lib/nls/msg/ru_RU/%N.cat
$
===>
F3=Exit
F13=Clear
F6=Print
F17=Top
F9=Retrieve
F18=Bottom
F11=Truncate/Wrap
F21=CL command entry
We see that i5/OS PASE is running with CCSID 915, which happens to be one of the main
ASCII CCSIDs for Cyrillic.
For a full discussion of i5/OS PASE, see:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=/rzalf/rzalf
intro.htm
PHP
The most important configuration parameter from a language perspective in PHP is the
default_charset directive. Some plug-ins, such as the DB2 and ODBC drivers, use the value
of this directive to determine what sort of data transformation is required.
This directive can be found in the php.ini file, which by default on i5/OS is located in the
/usr/local/Zend/Core/etc directory. Setting this directive causes PHP to add the configured
character set to be sent down to the browser in the Content-Type header.
Apache
For the most part, no special configuration of the Apache environments is required to modify
globalization settings. The HTTP servers largely act as a pipe, passing the PHP-generated
data straight through.
If you use straight HTML files in addition to PHP files, you might have to make sure that the
Content-Type header is set correctly. You can do this manually by adding the code to the
header section of each HTML file:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
108
CCSID
Description
EBCDIC
CHAR/VARCHAR
1025
UTF-8
CHAR/VARCHAR
1208
Unicode
GRAPHIC/VARGRAPHIC
13488
We could create a single table containing columns of these data types using the DDL shown
in Example 10-2.
Example 10-2 Creating table in i5/OS with three Russian character encodings
109
examples and focus on using UTF-8 to enable the support, which is perhaps the most popular
method used.
Restriction: Currently it is mandatory to be signed on with the QSECOFR user profile (not
just a profile having *SECOFR authority) for the following support to work. This is due to
the way Apache security code is written.
10.2.1 i5/OS
As described earlier, change the i5/OS job to be configured for the Russian language:
CHGJOB LANGID(RUS) CNTRYID(RU) CCSID(1025)
This is the only thing that has to be done in i5/OS. Remember that you have to be signed on
as QSECOFR to make this work.
10.2.3 PHP
Edit the main PHP configuration file, either via the administration console or directly by editing
it manually.
We use Notepad to edit the file, which you can find (php.ini) in the following directory:
/usr/local/Zend/core/etc
You will find a default_charset directive there that is commented out. Copy it, remove the
comment (semicolon) from the front, and change the value to "UTF-8". It should look like this:
default_charset = "UTF-8"
10.2.4 Apache
Special configuration is not required in the Apache environment. However, we cannot use the
menu options provided by Zend (GO ZENDCORE/ZCMENU) to stop and start the PHP
environment because they do not correctly configure the i5/OS PASE environment.
110
apachectl -k start
apachectl -k stop
apachectl -k restart
This should get the PHP server going with the desired configuration.
Tip: You can imbed the following code in a PHP file to see the i5/OS PASE environment
settings that the PHP engine is running in:
<?php
phpinfo (INFO_ENVIRONMENT);
?>
111
112
11
Chapter 11.
113
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $template->doctitle ?></title>
</head>
<body>
<?php echo $template->contentTitle; ?>
<?php echo $template->content; ?>
</body>
</html>
The next step consists of creating a class called Template with the appropriate functions (see
Example 11-2). Our main method, show($doc), receives the name of a document to be
displayed as an argument. It sets the path, which is empty in our example, and then executes
the template by using the PHP function include().
After that it calls the function showFooter(), which prints a line with the current date and the
current working directory.
Example 11-2 Definition of class Template (TemplateClass.php)
<?php
class Template {
public $template_dir;
function show($doc) {
$template = $this;
include($this->template_dir.$doc);
$this->showFooter();
}
function showFooter() {
printf("<br><br><br>Today's date: %s | Current directory: %s", date('d. M
Y'), getcwd());}
}
?>
Now all that is needed is the main document, which first includes the template class file. Then
it creates a new instance of the class Template and assigns values to the class attributes.
114
Finally, the function show(Template.tpl) displays the template file, parsing and replacing
the values according to what has been set in the file.
Example 11-3 TemplateMain.php, our main file
<?php
include('TemplateClass.php');
$template = new Template;
$template->doctitle = 'PHP using an HTML template';
$template->template_dir = '';
$template->contentTitle = '<h3>PHP using an HTML template</h3>';
$template->content = 'Hello, World';
$template->show('Template.tpl');
?>
Example 11-4 shows a more complicated example that combines templates with retrieval of
an i5/OS spooled file.
Example 11-4 Combining templates with retrieval of an i5/OS spooled file
115
HTML_Template_Flexy (http://pear.php.net/package/HTML_Template_Flexy)
HTML_Template_PHPLIB (http://pear.php.net/package/HTML_Template_PHPLIB)
HTML_Template_IT (http://pear.php.net/package/HTML_Template_IT)
HTML_Template_Sigma (http://pear.php.net/package/HTML_Template_Sigma)
HTML_Template_Xipe (http://pear.php.net/package/HTML_Template_Xipe)
In addition to those listed on PEAR, we recommend that you look at the following PHP
template solutions:
Smarty (http://smarty.php.net/)
TinyButStrong (http://www.tinybutstrong.com/)
If you are more interested in code maintainability and portability, we suggest that you refer to
the next section, where you can read more advanced techniques and start learning about
recommended design practice when building your PHP project.
116
The controller also implements security precautions, such as validating and cleansing
user input before passing it to the model to be processed.
The model
The model consists of our application business logic and objects. This is usually
implemented as a collection of PHP 5 classes. It uses an intermediary data access object
that makes calls to a database interface. The database interface translates commands and
provides them to the runtime implementation regardless of the actual database or PHP API
for communicating with it. Regardless of the exact database interface, the model objects
receive data in the same format and do not need to change if the data tier changes.
In reality, each of these logical separations overlaps a bit into the others. For example, many
PHP applications have some controller code in the view pages and some model class names
mentioned in the display pages, despite a strong MVC approach.
Luckily, there are MVC frameworks that can help you with MVC design in your future PHP
applications. Examples include:
CakePHP (http://www.cakephp.org/)
Agavi PHP MVC Framework (http://www.agavi.org/)
Phrame (http://www.phrame.org/)
Claw (http://claw.tigris.org/)
The Ismo PHP Framework (http://ismo.sourceforge.net/)
PHP on TRAX (http://www.phpontrax.com/)
Symfony (http://www.symfony-project.com/)
Livepipe: Pipeline Framework (http://livepipe.net/pipeline/)
Zend Framework (http://framework.zend.com)
You can find more MVC frameworks for PHP and their quick comparison at:
http://www.phpwact.org/php/mvc_frameworks
When this book was written, most of the listed MVC frameworks did not support IBM DB2 as
data source, but did support MySQL or PostgreSQL. In order to work with IBM DB2
databases, you should use ODBC connectivity if possible.
In short, although PHP and Web applications are gaining prominence as an excellent way to
build applications quickly, it should be paired with time-tested software development
principles to build flexible and maintainable applications.
If you want to know more about the best methods to design your Web application, a good
resource for planning your PHP application architecture is Sherri Wheelers Mature Design
Theory in Web Development:
http://www.zend.com/php/design/mature-design.php
A high-level, theoretical discussion of application architecture called What is a software
architecture?, written by Peter Eeles, is available in the Rational Edge:
http://www.ibm.com/developerworks/rational/library/feb06/eeles/
117
118
Related publications
The publications listed in this section are considered particularly suitable for a more detailed
discussion of the topics covered in this redbook.
IBM Redbooks
For information about ordering these publications, see How to get IBM Redbooks on
page 120. Note that some of the documents referenced here may be available in softcopy
only.
Bringing PHP to Your IBM eSeries iSeries Server, REDP-3639
Developing PHP Applications for IBM Data Servers, SG24-7218
IBM HTTP Server (powered by Apache): An Integrated Solution for IBM eSeries iSeries
Servers, SG24-6716
IBM System i Security Guide for IBM i5/OS Version 5 Release 4, SG24-6668
Preparing for and Tuning the SQL Query Engine on DB2 for i5/OS, SG24-6598
SQL Performance Diagnosis on IBM DB2 Universal Database for iSeries, SG24-6654
Other publications
These publications are also relevant as further information sources:
Beginning PHP and MySQL 5: From Novice to Professional, 2nd Edition, W. Jason
Gilmore, ISBN 1590595521
Learning PHP 5, David Sklar, ISBN 0596005601
PHP Cookbook, 2nd Edition, Adam Trachtenberg, et al, ISBN 0596101015
Online resources
These Web sites are also relevant as further information sources:
Zend site for i5/OS
http://www.zend.com/products/zend_core/zend_for_i5_os
IBM site for Zend Core
http://www-304.ibm.com/jct03002c/software/data/info/zendcore/
Site with many useful PHP links
http://www.ibm.com/developerworks/opensource/library/os-php-read/
Pair J2EE with PHP to implement a common Web application infrastructure
http://www.ibm.com/developerworks/websphere/techjournal/0505_krook/0505_krook.html
Use PHP on System i: An overview, sample applications, and one groups experiences
http://www.ibm.com/developerworks/systems/library/es-path2php/
119
120
BDB
BerkeleyDB
CCSID
RSTLIB
RSTLICPGM
CFGTCP
Configure TCP/IP
RTVNETA
CLI
CLR
SAV
Save Object
CMS
SAVLIB
CPAN
SDO
cURL
client URL
SOA
DAS
SSL
DDL
UDB
Universal Database
DLTLICPGM
V5R4
Version 5 Release 4
DML
WRKACTJOB
DMZ
Demilitarized Zone
WRKAUT
DSPOBJAUT
WRKPTFGRP
DSPPTF
Display PTF
WRKUSRJOB
GRTOBJAUT
WRKUSRPRF
GUI
ZENDCOREAP
IBM
IDE
Integrated Development
Environment
ISAM
ISO
ISP
ITSO
LDAP
LICPGM
Licensed Program
MVC
OO
Object Oriented
PASE
PEAR
PECL
RDBMS
RST
Restore Object
121
122
Index
32-bit 60
64-bit 60
MVC 117
mysql 75
MySQL AB 71
mysqli 75
Numerics
apachectl 34
NETSTAT 97
NOBODY user profile 70
C
CL call - Toolkit 52
column names 62
connection - Toolkit 51
controller 117
O
ODBC 60
open source 71
environment 60
extension 3
PDO_ODBC 60, 68
Perl 8
persisted information 40
Personal Home Page/Form Interpreter 8
PHP 5 8, 117
PHP community 8
PHP Data Objects 68, 77
php.ini 88
PHP/FI 8
Practical Extraction and Reporting Language 8
program call - Toolkit 52
programming interface 60
programming language 3
database solution 60
DB2 family 60
DB2_ATTR_CASE 62
DB2_CASE_LOWER 62
db2_connect 64
Demilitarized Zone 89
DMZ 89
DSPRDBDIRE 60
firewalls 97
QSQSRVR 62, 70
httpd.conf 88
I
i5_command 52
J
JavaScript 97
L
library 64
logic 40
M
Microsoft Internet Explorer 97
Mozilla Firefox 97
multiple installations 30
multiple instances 30
RDBMS 60
Redbooks Web site 120
Contact us x
relational database management systems 60
reliability 3
reverse proxy 25, 89
RSS parser 54
S
schema 64, 71
security 71
server mode - ibm_db2 62
SimpleXML extension 54
SOAP 5556
SSL 88
stability 3
123
T
Toolkit
CL call 51
connection 51
program call 52
U
upper-case 62
V
V5R3 4
V5R4 4
W
WRKRDBDIRE 60
X
XML 54
XML-RPC 55
Z
z/OS 60
Zend engine 8
ZENDCORE 89
124
(0.2spine)
0.17<->0.473
90<->249 pages
Back cover
This IBM Redbook will help you install, configure, and become
productive with PHP on System i using Zend Core for i5/OS and
Zend Platform for i5/OS. If you are evaluating PHP, this book will
also help by providing background information and comparisons
with other tools.
Some of the topics addressed include:
Installation, configuration and administration
Application development
Strategies to access DB2 for i5/OS and MySQL data from
your PHP applications
Security, performance, troubleshooting, and more
Emphasis has been placed on highlighting i5/OS-specific
functions and features in this book rather than those generic to
PHP on all platforms.
INTERNATIONAL
TECHNICAL
SUPPORT
ORGANIZATION
BUILDING TECHNICAL
INFORMATION BASED ON
PRACTICAL EXPERIENCE
IBM Redbooks are developed
by the IBM International
Technical Support
Organization. Experts from
IBM, Customers and Partners
from around the world create
timely technical information
based on realistic scenarios.
Specific recommendations
are provided to help you
implement IT solutions more
effectively in your
environment.
ISBN 0738489875