(click to open)

Quick Page Table of Contents


Zend PHP Toolkit

Goto Main Page
Goto Documents

Who is this page for?

Instructions designed for IBM i developer learning PHP starting from ground zero …

  • … installing PHP on a laptop
  • … little control over IBM i machine (can’t install Zend Server on IBM i)
  • … but have a DB2 Connect DRDA connection or ODBC iAccess connection to IBM i (good enough)


On IBM i …

  • recent IBM i DB2 PTFs or XMLSERVICE clobs will fail (PHP ibm_db2 drivers)
  • XMLSERVICE PTFs from IBM in QXMLSERV library (see main page for PTF numbers)

On laptop DRDA or ODBC …

1) Install PHP on your PC/laptop

Download Zend Server …

  • {Zend Download site} - Zend Server Community Edition
    • … click download for your laptop (Linux, Mac, Windows)
  • Install Zend Server on your laptop
    • php-x.x-extra-extensions-zend-server — Linux install extra to run odbc

Download PHP toolkit and CW …
{Goto Main Page} and {Download Latest} version of cw-php-x.x.x.zip PHP framework. This zip file contains all the PHP code required to use the new toolkit from your laptop (your DB2 Connect).

Follow the instructions below to install the php code (Linux, but Windows similar) …

cd /usr/local/zend/share
sudo unzip cw-php-1.1.2.zip
sudo mkdir ToolkitApi
sudo mv ToolkitApi.zip ToolkitApi/.
sudo unzip ToolkitApi.zip
sudo gedit php.ini &
; UNIX: "/path1:/path2"
include_path = ".:/usr/local/zend/share/ToolkitApi:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear"
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Note: If you are using the IBM i PTFS for XMLSERVICE change toolkit.ini: XMLServiceLib = “QXMLSERV”. Also check the lugconnect PHP script and change XMLSERVICE library to QXMLSERV as needed.

Run ibm_db2 to IBM i

Need some tests to try (a few include with XMLSERVICE) …

> call crttest

Step 2) Configuration

  • DRDA connection to IBM i (DB2 Connect product) or iAccess ODBC connection to IBM i (Client Access ODBC)
    • If you need help with ODBC or DRDA please return to main page and review topic under laptop.

Step 3) Example - PGM complex data with DS

Example calling a typical IBM i functions with a few parameters.

How to select odbc or ibm_db2 (laptop)?

//The ToolkitService connection method/function uses either IBM_DB2(default)or ODBC extensions to connect
//to IBM i server. In order to switch to ODBC connection assign an "odbc' value to the $extension varibale
//and make sure that the ODBC extension is enabled in the PHP.INI file. 
try {
    $ToolkitServiceObj = ToolkitService::getInstance($db, $user, $pass, $extension);

    catch (Exception $e)
        echo  $e->getMessage(), "\n";

If you would like additional information on ibm_db2/ODBC connections to XMLSERVICE try these links.

Step 4) Disconnect

How you choose to run your toolkit will greatly affect the overall performance.

  • If you choose DB2 persistent connections (db2_pconnect), your performance can be very good.
  • If you choose toolkit internalKey you can run even faster, but …
    • If you choose toolkit internalKey, avoid using disconnect or you may loose your performance advantage.Toolkit disconnect end of each script will start/stop xmlservice toolkit jobs each request (XTOOLKIT jobs), a bad idea in a web environment (maybe even a disaster). Better strategy, allow XTOOLKIT jobs to simply timeout with idle settings (toolkit.ini), or operator kill *IMMED when not using jobs anymore.
      /* do not use with internalKey */ 


Tony “Ranger” Cairns - IBM i PHP / PASE