Connect your PHP applications to resources on your IBM i (evolved from AS/400, iSeries) using the open source (free!) PHP Toolkit for IBM i.
Co-developed by Alan Seiden and maintained by the IBM i community, the toolkit is also known as the XML Toolkit because the PHP front end and the XMLSERVICE RPG back end communicate via XML.
Sample scripts, options, and other resources
- Toolkit Usage Examples (more are added regularly)
- Data Types for XMLSERVICE and the PHP Toolkit
- Calling Procedures and Service Programs with the PHP Toolkit for IBM i
Where to find the PHP Toolkit
- XMLSERVICE (back end for the toolkit)
- Comes pre-installed by IBM in the QXMLSERV library
- To view its source code: https://github.com/IBM/xmlservice
- PHP Toolkit (front end)
- On IBM i, automatically installed with both Seiden PHP+ and Zend Server
- Or…download from https://github.com/zendtech/IbmiToolkit
- Or…install via Composer (“composer require zendtech/ibmitoolkit”)
To work with PHP what exactly do I need to download and install on System i and on Windows?
What configuration manuals or examples can help me?
Thanks for your help.
Angel, if you run PHP on Windows, I’d suggest installing the PHP Toolkit using the “install via Composer” instructions above, or by copying the code down from Github. The toolkit is just PHP code. Nothing needs to be installed on the IBM i. Connect using the PDO_ODBC transport option, as shown in one of the sample scripts (linked above).
We are using the iToolkitService.php to call an RPG service program to retrieve data for a simple PHP display. Recently, we switched that RPG service program from an outside purchased http post procedure to the IBM http sql functions, in this case HTTPGETCLOBVERBOSE. The XMLSERVICE job is no longer returning the needed data, and there are various sql and java errors in the logs.
JVAB309
User-defined function error on member QSQPTABL. SQLSTATE 58004.
SQL4301 Java interpreter startup or communication failed for reason code 1.
Is there another parameter I should be using here?
$obj = ToolkitService::getInstance($system, $user, $pwd);
$obj->setToolkitServiceParams(array(‘InternalKey’=>”/tmp/$user”));
Hi, Erica, I’ll contact you offline, then we’ll post the answer here later.
For anyone reading Erica’s question above, the issue had to do with the Java environment. She ended up rewriting some of the functionality to not need the HTTP SQL functions (Java underneath). There is an alternative now, however, available in TR5 (https://www.ibm.com/support/pages/ibm-i-74-tr5-enhancements), a new set of HTTP functions that do not need Java to run (https://www.ibm.com/support/pages/node/6486889) that would avoid any issues related to the JVM environment.
Hello Alan,
I have a problem with a CLLE that I am calling with a pgmcall.
In this program I run sql on PF (create, insert, delete….).
It works fine on our as400 but when I call it via php nothing seems to have been executed.
Would you have encountered this problem?
Regards
Hi, Isabelle, I’d guess there’s an error somewhere in the program call. I suggest you create and inspect a debug log to find out: https://github.com/zendtech/IbmiToolkit/blob/e5c6ee712d530c272c648e56ff18b7b32cecb0a0/samples/options.php#L48
Contact me offline with details of the debug log if you want to.
If XMLSERVICE is installed and setup on the IBMi with an apache instance could the PHP Toolkit be used on another webserver such as windows?
Would the only requirement be that the toolkit PHP need to be placed on the windows webserver?
I see with Zendserver for windows they have the toolkit plugin, but we are looking for a cheaper (or free) solution for the hosting.
We are looking to keep the web server hosting for the front facing pages off the IBMi but use the toolkit functions for the ease of use of IBMi resources like program calls ect.
Hi, Jason, that’s correct. XMLSERVICE comes pre-installed in QXMLSERV these days. You’d only need to install the toolkit PHP with your front-end code (in your case, a Windows server). Choose a “transport” that can connect to the IBM i without needing a license. PDO_ODBC or odbc or HTTP would be good options. Let us know if you need any help. Alan
Hello Allan,
I’ve been working on a project converting net.data to php. For the most part, I’ve been having pretty good success. But every now and then I run into a snag. One such snag is with tool kit. In net.data, you can call a CL program directly from a net.data document that can create a workfile in qtemp that you can later run sql over in the same net.data document. I’m not able to do that in tool kit because it runs in a different job. So instead, I’m loading a multidimensional array using a prototype program. It works if I call the prototype program directly. But if I call a CL program in-between for the purpose of running an opnqry statement, the process errors. It seems to be working until it gets to the IPLUGR512K procedure.
Any thoughts?
Thank you,
Brian Zeuske
Hi, Brian, if you use stateless mode then the CL program would run in the same job as SQL, if called within the same PHP request, thus QTEMP should be fine. I get the impression that there is more to your question. It seems a little complicated for a comment on this page. Maybe you should email me with more details. — Alan
I tried xml toolkit but it seems it doesn’t support large query, i tried to fetch 10000 records and it generate an error on AS400, is there some limitation that you are aware of?
Alessandro, no limitations. You probably need to set a higher plugSize.
If You have problems with passing parameters, just write to database file, and the target program will read it. Just as simple as that.
I am trying to connect ibm iseries using zend framework 2 through localhost. I have configured database details in global.php now need to call stored procedure using database object. I have gone through the questions answered by you on stackoverflow but I am unable to do anything and I have blocked.
Can please help me in this,
Praveen, are you connecting from a PC?
Hi, Peter,
I’m working on a toolkit update to support PCML with PgmCall. Do you use PCML heavily?
PCML is currently supported only by the compatibility wrapper [CW], but because new projects should use the new toolkit API (PgmCall, etc.) instead of CW, I intend to add PCML support for PgmCall.
Tell me more about your requirements if you would like, perhaps through my contact page.
Best regards,
Alan
Full support for PCML was added as of toolkit 1.6.
Hello Alan, last year I attended one of your presentations on PHP on IBM i. Very interesting. I now have a problem with the API Toolkit, and so farI didn’t find any answers. Is there a way to declare parameters für the PgmCall method by way of using PCML? A short answer would be appreciated.
Regards from Germany
Peter
Hi, Klaus-Peter, PCML support exists for the Compatibility Wrapper (CW) only. Do you still need it? Let us know.
Could you recommend a site that explains and gives example of passing multi occurrence parameter to and RPG program and return parameters. We are stuck at work and do not know where to look
Hi, Barbara, we’ve written an example of multi-occurrence parameters here: https://github.com/zendtech/IbmiToolkit/blob/master/samples/data-structure-array-with-counter.php