Innovate faster and cut risk with PHP experts from Zend Services.
Beginning to advanced PHP classes to learn and earn global certification.
Help me choose >
Submit support requests and browse self-service resources.
Late last year I wrote a blog showing the ease of getting PHP on the platform with Zend Server as well as the complete integration of PHP with the rest of the system (i.e., Apache, Db2, ILE programs and objects). With our recent release of ZendPHP for IBM i, you may be wondering if we still followed the same one-and-done approach to installation... and the answer is a resounding yes!
While the installation method has changed from Licensed Program Product (LPP) to RPM Package Manager (RPM) the same integration aspects of the product are there. Read on as I walk you through the simplicity of installing ZendPHP on IBM i, as well as Db2 and ILE integration.
Let’s begin with the installation. To start, as I mentioned in the introduction, ZendPHP is provided as a set of RPM packages and as such it follows the installation and update processes of other open-source packages. The packages reside in what is referred to as a package repository, and it is from there that the package is installed. There are a number of setup steps that you could perform manually such as defining the package repository on your system, setting a search path for executables, and establishing a home directory, or you could leverage a setup/installation script that we provide.
To obtain the script, you register for ZendPHP and we send installation instructions that detail how to retrieve and execute the script to you. Keep in mind that the package is being installed in the PASE environment using the open-source ecosystem (OSE) so you would need to have the open source bootstrap already installed – if you need more information on that, reach out to us!
Once the bootstrap is installed you are ready to install ZendPHP. To access the PASE environment you will need to establish a terminal session either through QP2TERM (not recommended) or via SSH (recommended). SSH is the recommended approach as it adheres more closely to what open-source packages expect with regards to items such as process identification/environment and has a number of useful features including the bash shell with command history and file-name completion. You are now ready to install ZendPHP – navigate to the directory where you placed the ‘zendphp_manage.sh’ script that was obtained via the registration link and execute it as follows:
You will observe a number of messages displayed indicating various packages being installed. After a few minutes the command prompt is redisplayed, and the installation is complete. Now let’s see if it actually worked.
Recall that I indicated earlier that one of the integration points provided with ZendPHP is integration with the Apache web server, so let’s check that out first. The Apache configuration (which can be found at /www/zendphp/conf/httpd.conf) is configured with the DocRoot (the default location for scripts) as /www/zendphp/htdocs so first let’s put a simple PHP script named hello.php in that directory:
echo "Hello world - ZendPHP is sure easy to install!!!";
Executing the script can be accomplished one of two ways – if you want to simply execute it from the terminal window then you can use the PHP CLI as follows:
Assuming no typos are present in the script, then you should receive the following output:
Hello world - ZendPHP is sure easy to install!!!
But that doesn’t really prove that ZendPHP is integrated with Apache! To prove that, let’s run the same script from a web-browser as follows:
http://<IBM i system>:10080/hello.php
The following output should be displayed in the web browser:
One thing to note here is the port number. The default port (or virtual host) that ZendPHP uses is 10080; however, if an installation of Zend Server is also on the system then a different port number will be used which can be found in the Apache configuration file identified earlier. Why is this important? Put simply, it means that ZendPHP can be installed alongside Zend Server in the same way that simultaneous installations of Zend Server has been supported for many releases.
Up to this point we have shown that the installation of ZendPHP is accomplished with a single command and that Apache integration is part of the installation. Let’s move on and show the Db2 integration.
Place the following script (call it something like db2test.php) in the docroot (/www/zendphp/htdocs):
$conn = db2_connect('*LOCAL', '', '');
$result = db2_exec($conn, "SELECT * FROM QIWS.QCUSTCDT");
$firstRow = db2_fetch_assoc($result);
echo print_r($firstRow, true);
The script leverages the QCUSTCDT schema that is delivered with IBM i. Like the previous script, this script can be run either through the CLI or via the web server. I went ahead and ran it through the CLI as follows:
Which resulted in the following output:
[CUSNUM] => 938472
[LSTNAM] => Henning
[INIT] => G K
[STREET] => 4859 Elm Ave
[CITY] => Dallas
[STATE] => TX
[ZIPCOD] => 75217
[CDTLMT] => 5000
[CHGCOD] => 3
[BALDUE] => 37.00
[CDTDUE] => .00
So, now we have shown that Db2 integration is delivered with ZendPHP.
The final item to show is ILE integration. Let’s place the following script (call it iletest.php) into the docroot (/www/zendphp/htdocs) directory:
$obj = ToolkitService::getInstance();
$rows = $obj->CLInteractiveCommand('DSPLIBL');
echo '<pre>' . print_r($rows, true) . '</pre>';
Like the other scripts, this script can be run either through the CLI or through the web-browser and again I chose to run it through the CLI as follows:
This generated the following output, showing that the CL command DSPLIBL was executed:
 => 5770SS1 V7R4M0 190621 Library List 2/09/21 6:14:46 Page 1
 => ASP
 => Library Type Device Text Description
 => QSYS SYS System Library
 => QSYS2 SYS System Library for CPI's
 => QHLPSYS SYS
 => QUSRSYS SYS System Library for Users
 => QGPL USR General Purpose Library
 => QTEMP USR
 => * * * * * E N D O F L I S T I N G * * * * *
Just like Zend Server, ZendPHP supports a one-and-done approach to installation as well as delivery/integration of key aspects of using PHP on the IBM i platform. This blog has demonstrated the ease of installation of ZendPHP along with the ability to access Db2 data and ILE programs and objects “out-of-box”.
One closing thought: as I indicated in my earlier blog on ZendPHP, ZendPHP is another offering from Zend that delivers PHP to the platform – it is not a replacement of the full-featured Zend Server. But it is a viable option for those who are looking to use a PHP stack without the application server functions that Zend Server delivers. In a future blog I will show the same ease of installation of Zend Server 2020 which is also packaged as an RPM instead of the predecessor LPP.
Ready to give ZendPHP a spin? Click the button below to register for your free download.
Try ZendPHP Free
IBM Champion | Former - Senior Solutions Consultant, Zend, Perforce Software
As an IBM champion, Mr. Earley has been recognized as a leader in the IBM i community and offers more than 20 years of experience helping customers to implement solutions on the platform. His expertise includes using PHP, MariaDB, Docker, and Chef for creating modern enterprise solutions that run on IBM i, as well as PowerVC for cloud deployments and virtualization management. Mr. Earley is a frequent speaker at global technology conferences, and he has authored numerous articles on Linux, PHP, virtualization, systems management, and open source solutions and concepts.