PHP Toolkit Install

(click to open)

Quick Page Table of Contents


PHP Toolkit Install

Goto Main Page
Goto PHP page
Goto Documents

Zend Server PHP Toolkit (client)

PHP Client: Toolkit API and Compatibility Wrapper (CW)

This download includes PHP new Zend Toolkit and PHP original toolkit compatibility layer (CW), you may develop applications for either interface from your laptop or on your IBM i web server using the support DB2 stored procedure interface to XMLSERVICE (iAccess odbc, DB2 connect).


XMLSERVICE library installed on IBM i machine. Zend Server installation includes a version of XMLSERVICE library, and provides periodic PTFs to Zend Server product, therefore you need only download a new version if you are having an specific XMLSERVICE issue.

  • {IBM PTFs} for Java (PASE), HTTP, DB2
  • {Zend Server} Zend Server for IBM i tab.
    Zend Server 5 settings
    XMLServiceLib = "ZENDSVR" 
    debugLogFile = "/usr/local/zendsvr/share/ToolkitApi/debug.log"
    logfile = "/usr/local/zendsvr/share/ToolkitApi/toolkit.log"
    define('ZSTOOLKITLIB', 'ZENDSVR');
    Zend Server 6 settings
    XMLServiceLib = "ZENDSVR6"
    debugLogFile = "/usr/local/zendsvr6/var/log/debug.log"
    logfile = "/usr/local/zendsvr6/var/log/toolkit.log"
    define('XMLSERVICELIB', 'ZENDSVR6');
    define('ZSTOOLKITLIB', 'ZENDSVR6');
  • If your machine DSPSYSVAL QCCSID is 65535 (means no CCSID or hex/binary), set CCSID /www/../conf/httpd.conf or NOTHING works (hours of trouble).
    DefaultFsCCSID 37
    CGIJobCCSID 37
  • When running DBCS on IBM i and see “bad character data” (Chinese characters), set CCSID /www/../conf/fastcgi.conf
    setSetEnv="CCSID=1208"; SetEnv="LANG=C"
  • V5R4 OPM/CLP call failure notice or when calling RPG w/optional %parms


Instructions after download and unzip

  1. unzip, then copy contents into /usr/local/zendsvr/share/ToolkitApi (overwrite existing contents)
  2. CHGAUT OBJ(‘/usr/local/zendsvr/share/ToolkitApi’) USER(QTMHHTTP) DTAAUT(*RWX) OBJAUT(*ALL) SUBTREE(*ALL)
  3. see readme file
    - CCSID 65535 machines read FAQ
    - develop on your laptop?
      copy PHP /ToolkitApi directory to your laptop
      and use a DB2 connection to XMLSERVICE 
      (iAccess odbc, DB2 connect) 
    As noted in the readme file:
      If you are using the CW, and used i5_program_call(), 
      i5_userspace_get(), or i5_command() from inside a function,
      and you get output variables from them, please add the line:
      if (function_exists('i5_output')) extract(i5_output());
      after the i5_ call. This will make the variables available 
      to your script.
      (See the readme file for details.)


See readme file for information on toolkit.ini setings.

Optional: CWDEMO library (zipped SAVF)

Test/verify used by cwtest script with PHP CW.
2011–11–18 -

  1. Unzip to cwdemo.savf
  2. FTP cwdemo.savf to QGPL library (empty savf must exist already)
    Note: CCSID 65535 machines read FAQ

Optional: PHP pear tests

2012–12–04 -
2012–10–17 -
2012–09–17 -
2012–08–15 -
2012–02–29 -
2011–10–24 -


  1. unzip
    > cd /home/myplace
    > unzip
    > edit authorization.php (see notes)
  2. Run tests:
    call qp2term
    > export PATH=/usr/local/zendsvr/bin:$PATH
    > export LIBPATH=/usr/local/zendsvr/lib
    > cd /home/myplace
    > pear run-tests *.phpt
  3. readme
    -- CCSID 65535 machines read FAQ
    -- phpt tests use XMLSERVICE library (main RPG download)
       call crttest  ... works V5+
       call crttest6 ... these tests only work V6+
    -- authorization.php 
       - profiles used
         $user = 'DB2'; <--- main test profile
         $pass = 'xxxxx';
         $adoptuser1 = 'TKITU1'; <--- switch profile
         $adoptpass1 = 'xxxxx';
       - odbc, ibm_db2, pdo_ibm must be enabled php.ini 
         and conf.d/ (or will skip)
       - pcntl must be enabled php.ini and conf.d/ 
        (or pcntl_fork not work few tests) 
       - GET/POST test require installed XMLCGI interface 
         Apache (or will skip)
         $i5rest   = "http://mymachine/cgi-bin/xmlcgi.pgm";
    -- some tests may have hard coded profile/data/paths 
       (trying to fix over time)
    -- pear tests replace ibm_db2.ini for 
       ibm_db2.i5_ignore_userid=1 tests
       -- make a copy config.d/ibm_db2.ini
       -- suppose to return to normal last kill test 
    -- Yips machine note: 
       - if you delete all spool file one of demos 
         is look for spool data for QTMHHTTP ... to fix ...
         SBMJOB CMD(QSH CMD('/QOpenSys/usr/bin/sh -c 
           "/QOpenSys/usr/bin/ps -ef | grep qtm" 2>&1')) 
         SBMJOB CMD(QSH CMD('/QOpenSys/usr/bin/sh -c
           "/QOpenSys/usr/bin/system wrkactjob" 2>&1')) 

Optional PECL memory driver

Experimental PECL extension allows XMLSERVICE to run in PHP-CGI job or state full second job (ipc).
2013–08–23 -


See README zip file (dependency xmlservice 1.8.0+)


Add new ini file etc/conf.d/ibmi.ini


string i_xmlservice(string xmlin [, string ctl, string ipc, long pase_ccsid, long ebcdic_ccsid])
mandatory: xmlin - XML input
optional:  ctl - xmlservice control words ("*sbmjob *here *cdata ...")
optional:  ipc - private connection ipc/internalKey route to XTOOLKIT job ("/tmp/packers")
optional:  pase_ccsid - cssid for ascii-2-ebcdic conversion (input conversion)
optional:  ebcdic_ccsid - cssid for ebcdic-2-ascii conversion (output conversion)

Debug technique: It’s as easy as 1–2−3–4−5–6−7–8−9 :)

  1. Run the test script that contains control “*debug” and script will “hang” while it waits on #2
  2. A MSGW inquiry message in DSPMSG QSYSOPR will be generated by the toolkit. Note the job information (number, name, user) provided in the MSGW.
  3. STRSRVJOB using that job information as parameters.
  4. STRDBG with the program and library you wish to debug.
  5. Answer the MSGW. Any answer will do—”G” is fine.
  6. The RPG program source will appear in debug mode in your terminal, ready to step through, allowing you to inspect variables, etc.
  7. When done inspecting and stepping, let the RPG program complete (using function keys indicated on screen).

Other debug options …

           Job1 (threaded)   Job 2                        Job 3 (DB2 userid/password)    Job 4 (optional XTOOLKIT job)  
                             (ctl=*debugcgi)              (ctl=*debugproc)                (ctl=*debug)
browser -> Apache          ->XMLCGI (Apache CGI child) -> QSQSRVR (XMLSERVICE *here) 
                                                       -> QSQSRVR (XMLSERVICE client) -> XTOOLKIT (XMLSERVICE ipc=/tmp/flinstone)

$ctl .= " *debugcgi";  // Job 2 - debug XMLCGI to see REST/HTTP data passed by client (when using REST only)
$ctl .= " *debugproc"; // Job 3 - debug XMLSERVICE "client" to see DB2 passed data (DB2 interface)
$ctl .= " *debug";     // Job 4 - debug XMLSERVICE "server" to see XMLSERVICE calls (DB2 interface)
                       // Note:   when ctl='*here', both XMLSERVICE "client"/"server" 
                       //         are in QSQSRVSR job (NO XTOOLKIT job)
                       // remote: Attaching with LUW drivers changes QSQSRVR ...
                       //   CLIENT (Client Access drivers) <==> QZDAxxxx
                       //   CLIENT (DB2 Connect drivers)   <==> QRWxxxx