By David Shirey

PHP and the i, Part 1

By David Shirey

PHP and the i

We’ve talked about a lot of weird things so far on SitePoint (well, at least I think some of them are weird), but this may take the cake. In this series I want to talk to you about PHP – and the IBM I. That’s right, the IBM i, formerly known as System i and before that as the AS/400. Let’s start by dispelling the myth that the i is dinosaur; it’s actually a very wonderful machine, and there are lot of opportunities for brave PHP programmers who venture into this realm.

The Truth About the i

Before you get up in my face about the i being a dinosaur, not a real option in the high tech Windows 8 world of today, let me caution you that the closest I’ve ever come (as an adult) to getting into a fight in a bar was over the i. In my defense, I had just gotten off a four hour flight, it was late, and I was trying to catch the NFL scores for the day. Still, you might want to tread lightly here.

Yes, the IBM i has been around since the late 70’s or early 80’s depending on how you look at it. But it’s not an old fashioned machine and the kernel for Windows and Unix date from roughly the same time period.

If the adage comparing Unix to buying a car that you have to assemble yourself, and Windows to a car that needs to be repaired before you can drive it, is true, then it’s also true that the i is like getting a car off the showroom floor completely assembled and ready to go.

The hallmark of the i is its level of integration. All aspects of the machine are integrated: the language, the database, the operating system. It’s a very fast machine (up to Power-7 chips now), is very scalable (from blade servers to mega systems), and has a very advanced operating system that separates the hardware from the software (making it very easy and transparent to switch from 32-bit hardware to 64-bit with no changes required to the programs – this happened in the late 90’s; all i programs are 64 bit) and has a security structure that is unrivaled. No IBM i system has ever been successfully hacked.

OMG – it’s a system from heaven! So why doesn’t everybody have one? The i is a clear winner if you look at any study that focuses on the total cost of ownership over several years, but we are a quarterly-driven society. The acquisition price of the i is more expensive than a Windows server. Moreover, IBM has never seen fit to provide a native GUI interface to the i. Those who use green screens are loath to switch to a GUI or browser configuration because it’s so much easier to enter data and commands directly, but today’s reality is that you have to have a pretty GUI.

The i and GUI

So, we’ve proven that I love the i, but what does that have to do with you? For the past 40 years, RPG programmers on the i have been churning out green screens at an incredible rate. And now, suddenly, everyone wants them to produce browser-based screens. The problem is, there’s no native way to do this on the i (this isn’t the same as saying that there is no way to do this on the i, but rather that doing it is not something that RPG programmers naturally have their hands around).

We could replace RPG on the i with something that is browser-based. Maybe Java. Or .Net. The problem with this is that for business logic, which involves a lot of logic and calc and case structures, there is nothing better than RPG (unless you use COBOL to which most i people are severely allergic). As a result, RPG is here to stay and the basic programs required by the ERP systems that run on the i will continue to use RPG.

In the i world there are a number of options to creating the screens and then interfacing them with the RPG logic. And every educator in the i world is busy trying to entice RPG programmers to learn one of a number of options, PHP being one of them.

The problem that most RPG people face is that they have gone through multiple head count reductions over the past 10 years and most of them don’t have time to do what they need to do with RPG, much less learn something new. That means that the i world is in a position to use people who have PHP knowledge but don’t know anything about RPG.


RPG and Stuff

For those of you who don’t know anything about RPG (and I would guess that is most of you), RPG started out as a simple report writer. But nothing stays simple forever.

Initially, RPG people tended to write big programs, with a single program containing screen build, control logic, and business logic. But with the introduction of RPG ILE about 10 years ago, the tide began to turn. ILE made RPG much more efficient in how it called sub programs and now a lot of people are pushing the MVC pattern with RPG handling the model and controller but something else, like PHP, to do the view.

Most companies would use MVC except for one problem; their normal RPG programmers may be able to do ‘Hello World’ in PHP but they aren’t ready to develop complicated screens or deal with the network consequences of those screens (sessions, cookies, REST, etc.). That opens a real opportunity for PHP programmers who can do those kinds of things and who are willing to work within an i framework.

Getting Started

So with a potential revenue stream waiting to be tapped, the question is how do you, the PHP programmer, do just that?

First, get over thinking of the i as an outdated machine. I have yet to see anyone who gets familiar with the environment who doesn’t wonder why all computer systems are not like it.

Second, you need to gain some familiarity with RPG. No, you don’t need to know how to code it, but you should know how to deal with it. That is, how does RPG ILE work and how can you use it to allow you to do the screens (pages) for the RPG applications in PHP. Often, the people you will be dealing with will need to be helped to understand how PHP can fit into their plans and what they have to do to set RPG up to be PHP friendly.

Third, setting up business pages is different from pages for web sites, so one of the things you should do is become familiar with the differences and how to set them up for maximum efficiency.


That’s all they’ll let me write for this part. But stay tuned dear reader, as next week I’ll dive into what developing on the i is like for the brave PHP programmers who venture into this realm!

Image via Fotolia

  • Jon Paris

    Good to see IBM i get some exposure in the PHP world David. I know Alan Seiden has been presenting on the topic to PHP user groups and the more fol we can get interested the better. When I was at ZendCon I was asked questions like how did we handle scaling on the IBM i (we buy a bigger box) how do we deal with load balancing etc. (we don’t the system does it). And on and on. As you say many were oohing and aahing by the end of the conversation. Imagine that – a platform where you can get on with coding the app instead of dealing with all the other “stuff” that SQL Server and other platforms put you through.

    One small correction – RPG IV has been around for 20+ years. V5R1 (/Free) was 11 years ago!

    • david shirey

      Yes, I guess both of those products are that old. Doesn’t seem like it but you are right. Not really sure of the physics behind everything else getting older but me staying more or less the same.

  • Bruce Guetzkow


    Thank you for such an eloquent explanation of our beloved but misunderstood platform. Some of us are doing PHP on i (currently struggling, but plugging away). We’d love to introduce some PHP folks to this box & OS…can’t wait for part 2!

    • david shirey

      Thanks for your kind words. Keep punching! But it would be nice to bring a few PHP people into the fold. Would really speed up some of these projects where we i people are still in a learning curve.

  • PHP at last

    We did something like this in 1996, using Assembler programs on z/OS to leverage existing CICS logic and/or access underlying data in VSAM and DB2. Way faster and more secure than screen-scraping. It’s a shame we couldn’t get it marketed, but I’m still excited about the potential that PHP can bring to the platform.

    • david shirey

      Isn’t it interesting how many of these cutting edge things have been done, albeit with different tools, way back when. And it’s amazing how many good ideas are not picked up on immediately.

  • KT

    Very interesting. I come from a VAX/VMS background, and Digital Equipment (remember them?) and we always considered the AS/400 and IBM to be the competition. It is gratifying to see that this IBM “legacy” platform is still going strong.
    From an architectural perspective the IBM systems approach is what we aspired to imitate. Apparently it has aged well. This is good to see.
    I know what RPG is/was. I am familiar with PHP and the various issues and items mentioned in the article. And, of course I know Windows. But I was very gratified to read this article and I see it as an affirmation of what we used to do with “mainframe” client-server products. And to think that the “IBM-PC” was responsible for what may well prove to be a tangential development in large-system computing!

    • david shirey

      Oh yeah, I remember DEC. Seems to me one of the first places I worked had a 370 and also a VAX that they ran part of the business system on. Long time ago. Yep, I think there is still a place for the i in the web, especially with the arrival of the Power 7 and the nice pricing. Thanks for your comments.

  • ShadowCaster

    WTF did I just read? Huh?!

Get the latest in PHP, once a week, for free.