The PHP IBM i toolkit is a collection of PHP files that interact with XMLSERVICE on the IBM i to give you access to IBM i objects. I’ve been thinking that this approach was probably taken because it opens the doors to any programming language that wants to interact with the IBM i (PHP, Node.js, Ruby, asp.net etc… can all use this API). The problem I see with the current implementation is that requires xml encoding, xml parsing, and function calls that aren’t compiled. I think it makes sense that a PHP extension be written in C with hooks into the IBM i objects, much like how IBM_DB2.so php extension has hooks into Physical files, stored procedures, etc… IBM has C ILE that already can interact with all IBM i objects why not have a direct API to call from your PHP like db2_connect(). Your PHP project would call the compiled C PHP extension. There’s already a starting point since you can view the source of ibm_db2.so. Chuk from twitter mentioned creating it myself, which is tempting but unfortunately I’m not that familiar with “under the hood” of the IBM i.
Is it all about performance? Increase in usability?
- There has to be a balance between performance and the ability to get the job done quickly, and easily maintainable in the future.
- With the PHP extension it would make it more usable as you won’t have to worry about including the CW.php wrapper.
- You can use the function calls provided from the php extension anywhere.
- Upgrades are as simple as overwriting the .so file in the php extensions folder.
- You can extend the functionality and performance of PHP with a compiled PHP extension.
- You can create C ILE on the IBM i instead of using RPG ILE. Chris Hird says he does most of his development in C instead of RPG. If he wants to write an application on Linux he can keep using C. RPG is proprietary and stuck on the IBM i until IBM decides to open source it.
- Its popular based on TIOBE rating
Alternative to toolkit to access RPG, CL programs
- You can create external stored procedures that attach to RPG or CL Programs (any language in drop down below)
- QSYS.QCMDEXC can be called in a Stored Procedure to call CL (not sure about the other languages)
- The disadvantage is that you have to write and create the stored procedure for every External program. Which is not an optimal workflow for PHP development (Write PHP, Write Stored Proc, Create Stored Proc)
What is client IBM_DB2 PHP Extension look like under the hood?
So I looked into the IBM_DB2 c source code and figured out that its more like a wrapper around SQL* ODBC functions with additional specific DB2 features added on. So I guess that really wouldn’t be a starting point for accessing IBM i programs directly.
Responses from Twitter
— Chuk Shirley (@ChukShirley) January 28, 2015