Category Archives: PHP on IBM i

Whats going to change when I update PHP on IBM i. PHPinfo is a clue

e Here’s a great little script to see whats going to change when you update PHP on IBM i.  It compares the phpinfo from your production site to your new instance of PHP.  This way you can scroll down and take note of specific differences to PHP.  This isn’t all the changes so there’s more to check but can get you pretty far.

There is an issue with library lists if your using the PDO_IBM driver.

Disable Z-Ray on PHP on IBM i
Edit the file /usr/local/zendphp7/etc/conf.d/zray.ini and change zray.enable=1 to zray.enable=0

; Enable Z-Ray
; zray.enable=1

Custom PHP CLI php.ini configuration on #IBMi

If you ever want to run PHPCLI with a custom php.ini below are some steps to give you more information on how to set it up and learn whats currently in place for Apache (Webserver):

Cross-Site Request Forgery (CSRF) Prevention in PHP

Below is an example of how to prevent cross-site request forgery in PHP. Basically you create a form token tied to the user’s session. When the form is submitted we verify that they have a token and that its the token we issued to the user. If it’s not we don’t process the form and echo out an error message.

Compiling PHP extensions on IBM i / PASE/ AIX

This is post for Andy Youens and anyone looking to compile PHP Extensions on IBM i.  The first thing i would do is get GCC on the IBM i by following Tony’s guide here: .  GCC is the compiler system that can take a PHP extension  source code, which are written in C, and compile it into an .SO file that can be added via PHP.ini.  In Andy’s case he want’s xdebug and you can get the latest source code here: . Or find other versions here: .

Compile Script

Why can’t we just use any old binary? 

The source code has to be compiled to the processor and the operating system you’re running it on.  In the case of IBM i , the PASE environment is basically AIX (IBM’s flavor of UNIX) and it runs on IBM’s Power processor.

Binary compiled for PHP 7.1

 Further reading if you need more information to get strarted:


Who is Rogue Wave Software?

Well that’s the first question that came to my head when i found they were going to acquire Zend.  Below are some links to dive deeper into understanding what they do and offer.  It looks like they are a real good fit for PHP’s future and High-Performance computing.




Andi Guttman’s Linkedin message:


Klockwork – tool helps “developers create more secure and reliable software by analysing source code on-the-fly, simplifying peer code reviews, and extending the life of complex software.” –
IBM’s ILOG Visualization for C++ Products
Acumem – “performance tuning tools for single- and multi-threaded applications”  –
TotalView Debugger – insights into debugging high-performance computing (HPC) and supercomputing applications. –
Visual Numerics: advanced analytics software

Zend Acquisition PR

Geek Time’s Article

Check to see if Selenium Server is already running in PHP via Windows command line ( or any java jar file)

The script below will find out if the Selenium Server (java jar file) is already running in windows.  It uses the Windows Management Instrumentation Command-line (wmic) to look at the processes that are running as “java.exe” and gets the command line that started them.  The php script than Iterates through the command line output and looks for  “selenium-server-standalone”.

If you’re not familiar with Selenium you can learn how to use it with PHP here!

Automating Browser Testing with PHP and Selenium

Automated Browser Testing via PHP using Selenium and FB PHP-Webdriver

Automating your browser testing is very easy with using PHP and Selenium.  Below is a diagram of how it all works and the steps on how to achieve controlling your Browser with PHP!

Automating Browser Testing with PHP and Selenium

Automating Browser Testing with PHP and Selenium

Steps to install the basic components

  1. Install PHP on your machine download the PHP executable and set its path up in your environment (not sure how to do that?).
  2. Install Composer which will be used to download the source code for the facebook web driver
  3. Download the Selenium Standalone Server here (Direct link: selenium-server-standalone-2.53.1.jar)
  4. Run the selenium server by double clicking the jar file or invoking it from the command line..  You could also run this in your php script if you put the jar file in the same directory as the php script: exec(“java -jar “.__DIR__.”\selenium-server-standalone-2.53.1.jar”);
  5. Create a composer.json file
  6. Run composer install using the composer.json file – This will download the facebook web driver
  7. Create an example PHP script on your computer.
  8. Run the script on the command line C:\myscripts\> php example.php
  9. This should start your browser up and start running the example script code.  You could then use the web driver to screen scrape, enter in various input and take various actions that are needed to test your application out.  You’ll also have the power of PHP to do various things such as save the results of your test to a file and all this is done in PHP!  So you don’t have to learn another language.  You’ll also want to get comfortable with firefox’s developers tools so you can inspect an element and get a unique selector for that element so you know how to interact with that element.


  • Supported Platforms: Windows, OSX, Linux.  Not supported on the IBMi.  This makes sense since browsers run on a users machine not on the i.  Therefore to automate you may have to setup a Linux VM on a server and have it called to test.  Or you can run the code on your local machine


Adding PHP formatter to Selenium IDE firefox plugin to allow copying and pasting commands in PHP format

  1. Install the plugin here:
  2. In Selenium IDE go to Options->Clipboard Formatting-> PHP (PHPUnit)

This will give you output like this:

$this->type("name=field2", "99999");

which you’ll need to modify into this format if your using the PHP FB webdriver:


Adding a user extension to selenium IDE to add a new function

  1. Modify the user-extension.js that the selenium ide is using and add a function like this that will do an random email:
Selenium.prototype.doTypeRandomEmail = function(locator) {
    * Sets the value of an input field to a random email id,
    * as though you typed it in.
    * @param locator an <a href="#locators">element locator</a>

    // All locator-strategies are automatically handled by "findElement"
    var element =;

    /* The following block generates a random email string */
    var allowedChars = "abcdefghiklmnopqrstuvwxyz";
    var stringLength = 8;
    var randomstring = '';

    for (var i=0; i<stringLength; i++) {
        var rnum = Math.floor(Math.random() * allowedChars.length);
        randomstring += allowedChars.substring(rnum,rnum+1);

    // Append a domain name
    randomstring += ""

    // Replace the element text with the new text
    this.browserbot.replaceText(element, randomstring);
  1. Then you can just call the function like this:

Setting it up on an Amazon Linux EC2 instance

Follow this example to setup PHP on EC2 if you don’t already have a linux box to play with

Open the ports 7055 and 4444 on your EC2 server instance’s security group inbound rules

SSH into your Linux box run: