decorative image for blog on ibm i 7.5 for php
August 30, 2023

IBM i 7.5 for PHP: Exploring Db2 Services

PHP Development

With each new release of the IBM i operating system, and the various technology refreshes that come alongside them, we see amazing new features and enhancements that improve the development experience on IBM i. IBM i 7.5 is no different.

In this blog, I'll look at a few of those features available with IBM i 7.5 and/or released as part of a recent technology refresh, and the benefits they can provide to PHP users in particular.

Back to top

IBM i 7.5 Overview

IBM i 7.5, which released back in May of 2022, introduced a number of features and improvements to the IBM i platform. While I could spend the better part of a year unpacking and describing those improvements and their impact, today I want to look at the key features for teams using IBM i and PHP.

With that in mind, the biggest quality of life improvement for teams working with IBM i and PHP is the addition of new Db2 services.

Back to top

PHP Toolkit for IBM i, Meet Db2 Services

Back in 2005 when PHP was first coming to the platform, the folks at Zend asked me and several others what was needed to make PHP attractive. Hands down, we all chimed in with feedback that eventually became the PHP Toolkit for IBM i. Two iterations later, the toolkit is alive and well and still being maintained. But several of the features that were once the exclusive domain of the illustrious PHP Toolkit have since been made available as Db2 Services, including features like accessing spooled files, data areas, output queues, and more.

Performance and Resilience Improvements

One additional benefit of these new Db2 services is that they are lightning fast. Often, I hear IBM i folks talking about performance and this is a clear winner when upgrading your system AND PHP stack. Not only are PHP and the new POWER10 systems faster, but these services run circles around the old Toolkit as there is no XML translation required. 

In addition, the services tend to be a bit more resilient since there are so few moving parts. The examples shown were run on ZendPHP with PHP 8.2 and a Power10 server running IBM i 7.5 and the code just flies.

Boolean Data Type

Seeing support for the new Boolean data type is attractive as more and more APIs are dependent on upon JSON processing. IBM did not disappoint here with not only the new data type but also full support for the Boolean in the JSON functions inside of SQL.

Spooled Files

The PHP Toolkit for IBM i allowed users to download, print, convert, delete, or retrieve information related to spooled files. With the release of IBM i 7.5, that functionality is available as a set of commands in Db2 (covered below).

Data Areas

Here is a very simple example of retrieving all the data areas in a library and displaying their contents in a web page. This took many lines of code using the toolkit, but now only a few thanks to the new Db2 services that Scott Forstie and the IBM i team have developed. 

As an example, here is the PHP code for generating list of data areas and their values for a given library:

echo ("<h2>Data Area Examples</h2>");
$conn = db2_connect('*LOCAL', '', '');
$result = db2_exec($conn, $query);
echo "<pre>";
while ($row = db2_fetch_array($result)) {
    echo "DATA_AREA_NAME: " . $row[0] . "<br />";
    echo "DATA_AREA_VALUE: " . $row[1] . "<br /><br />";
echo "</pre>";

That code outputs as:


image showing data area examples from zend blog on db2 services


Output Queues

The PHP Toolkit for IBM i gives users a way to manage output queues, including listing of available output queues, submit output to output queues, as well as manage and monitor output queues. With IBM i 7.5, that functionality is now available via set of commands in Db2 (listed below).

Back to top

How to Take Advantage of the New Db2 Services

I realize the mantra of the RPG community is “if it works, don’t fix it”. But I have to argue that there is always an opportunity to address technical debt. As I said in a previous blog, Uncle Bob Martin likens refactoring to washing your hands as you leave the bathroom. I prefer to say something like please leave the code a little better than you found it. And updating these toolkit calls to use services is a great first step. Here is an example of some of the mappings of the toolkit calls to db2 Services.

Toolkit Function

Db2 Service

Data Area

DATA_AREA_INFO (View and function)

Spooled File

OUTPUT_QUEUE_ENTRIES() (View and function) 

User Spaces


Data Queues


System Values


Active Jobs


Object Information

OBJECT_PRIVILEGES() (View and function) 
(And a bunch for the IFS, too!)

Back to top

ODBC Example Using Db2

Above I illustrated an example using the standard Db2 PHP interface. Now it’s time to look at an ODBC example. Here we are using nothing but Db2 to collect information from a brand new service created for IBM i 7.5. This code might be even tighter because in addition to using ODBC we are also using PHP Data Objects or PDO. This construct abstracts a lot of the busy work in coding and renders it a bit cleaner.

 $dsn = 'odbc:*LOCAL';
$db = new PDO($dsn, $user, $password);
$URL = "";
echo ("<h2>IPs for URL</h2>");
foreach ($data as $row) {
    print( "Type: " . $row['ADDRESS_SPACE_TYPE']);
    print( "  IP: " . $row['IP_ADDRESS'] . "<br>");


image showing IPs for URL during ODBC demo with Db2


Back to top

Final Thoughts

While the Db2 changes above might seem like a limited benefit at a glance, the performance and resilience benefits are nothing to scoff at. When you take into account the updated support functionality included in the various operating systems and technologies used alongside IBM i, there will be ample reason for teams to upgrade IBM i versions.

Try Our PHP Builds on IBM i 7.5 for Free

Zend Server and ZendPHP now support IBM i 7.5, making it easier than ever to deploy and scale your PHP. Try for free via the links below.

Try Zend Server   Try ZendPHP

Additional Resources

Looking for additional IBM i resources? The resources below are some of our favorites.

Back to top