Innovate faster and cut risk with PHP experts from Zend Services.
See How Zend Helps Leading Hosting Providers Keep Their Managed Sites on Secure PHP
Learn PHP from PHP experts with free, on-demand, and instructor led courses.
Submit support requests and browse self-service resources.
Often when we talk about Zend Server we point out the benefits of Long Term Support (LTS) and the robust features of the Application Server, including functions such as application performance management (APM), code tracing, monitoring, and many others. While these features are significant, an often-missed advantage of Zend Server is the simplicity of installation and configuration, and it is that aspect that I would like to concentrate on in this blog.
Are you aware that, in a single step, you can go from an environment without PHP to being able to run PHP scripts? Let me take you through the step as well as demonstrate just how simple this is.
Current versions of Zend Server are installed as a Licensed Program on IBM i so, the method to install is as follows:
RSTLICPGM LICPGM(7PHPZND) DEV(*SAVF) SAVF(qgpl/zendphp7)
If you are an IBM i person you readily understand the above command. But, in the interest of completeness, here's a breakdown of the command:
So, what happens under the covers when the RSTLICPGM command is run?
First, a number of files are restored followed by a welcome screen that indicates what the rest of the process is going to do:
As you can see, a number of user profiles will be created along with a Library, subsystem, and directory structure (more on the directories in a moment). The only user interaction at this point is to press <ENTER> to accept the actions about to be taken.
The next thing that occurs is a a license agreement is displayed:
After reviewing the license agreement the <ENTER> key is used to accept it.
Now the installer really takes over and installs all of the files and performs all of the other actions indicated on the welcome page. When the installation is completed a final screen is displayed indicating that the installation is complete:
Press <ENTER> one last time and Zend Server is started and you're able to start executing PHP code. So, in summary, what did we do? We ran a single command and pressed the <ENTER> key a total of three (3) times. It doesn't get much easier than that!
Want to prove the point that we have a fully functional PHP? Let's create a PHP script in the document root that was automatically configured for us (/www/zendphp7/htdocs).
echo "Hello world – Zend Server is sure easy to install!!";
Call the script 'hello.php' (I'm just clever like that)
Now, point a web browser to the virtual host that was configured by Zend Server in the configuration file for Apache (10080) that is running in the subsystem that was created by the installer:
Want to see what gets output in the browser, you guessed it:
Hello World - Zend Server is sure easy to install!!
So at this point, we have shown that not only is PHP installed and functional, but an instance of the Apache web server was also configured to be PHP versant all without any user interaction!
By the way, if you are thinking that there is more work to be done to get access to Db2, nope! Consider the following script, again in the document root location:
$conn = db2_connect('*LOCAL', '', '');
$result = db2_exec($conn, "SELECT * FROM zendphp7.sp_cust");
$firstRow = db2_fetch_assoc($result);
echo "<pre>" . print_r($firstRow, true) . "</pre>";
If we call the script 'dbtest.php' it can be executed with the following URL:
And the following will be output:
[CUST_ID] => 1221
[COMPANY] => Kauai Dive Shoppe
[FIRSTNAME] => LINA
[LASTNAME] => Norman
[CIVIL] => 2
[ADDRESS] => 4-976 Sugarloaf Hwy
[ADDR2] => Suite 103
[CITY] => Kapaa Kauai
[STATE] => HI
[ZIP] => 94766-1234
[COUNTRY] => US
[PHONE] => 808-555-0269
[FAX] => 808-555-0278
And for the final conclusive evidence that everything needed was installed, let's create a simple script that uses XMLService to execute a CL command:
require_once zend_deployment_library_path('PHP Toolkit for IBMI i') .
$obj = ToolkitService::getInstance();
$rows = $obj->CLInteractiveCommand('DSPLIBL');
echo '<pre>' . print_r($rows, true) . '</pre>';
If we called the script iletest.php it can be executed via the following URL:
And the output from execution of the DSPLIBL command will be shown:
 => 5770SS1 V7R4M0 190621 Library List
 => 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 * * * * *
Pretty SLIC, right? (My IBM i friends will get that one.)
We have shown that with a single install we get a fully functional PHP complete with the driver for accessing Db2 data as well as the toolkit for leveraging XMLService to be able to integration with items such as CL commands, RPG programs, and more.
One quick comment on the demo scripts in this blog – they obviously don't follow good coding practice as they should, at a minimum, have error checking throughout. The point of these scripts was simply to demonstrate that the functionality of PHP, Db2 access, and ILE integration are all there simply by installing Zend Server.
In conclusion, PHP is not hard, integrating PHP with IBM is not hard, and just as importantly, getting PHP on the platform doesn't need to be hard either. Hopefully, this blog opened your eyes to the ease of getting PHP on the IBM i platform and the possibilities it presents.
This webinar looks at how users can understand and manage the PHP environment on IBM i
Looking for additional information on Zend Server or IBM i? Be sure to spend some time with these resources.
Try it today with a free, Zend Server trial.
Try Zend Server 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.