Installing and Using Apigility on IBM i

Install Apigility

I find the easiest way to accomplish this on the IBM i is to use PHP itself on command line:

After this is ran, Apigility will try to serve itself up. While it is successful in doing so, I have not been able to visit Apigility without errors when it is running this way on the IBM i. Therefore, I set it up normally through Apache:

That should do it! Apigility should be running fine at the address provided as ServerName.

Create a DB2 database adapter

Click on Database in the upper navigation, then click New DB Adapter in the content area. Fill out the necessary fields and click Save.

The adapter options can be added and edited through the interface as well:

If left with no options set, then we are limited to using the dot syntax, library.file, only. All column names will be uppercase as well. Some helpful options to set in local.php:

Create an API and a Service

This part is fairly straightforward. Either follow the official documentation for creating rest services, or create a simple REST service for test purposes, which is what I’m going to do here.

I created an API called Test with a REST service called Test. All the Test service does is return all PTFs with updates available when a GET request is sent for a collection.

So if we call through a service like Postman, we should get something like:

Poor Man’s REST

Instead of relying Entity and Collection definitions, which would be the proper way, I have used a barebones approach to creating RESTful services when on the IBM i. This is largely due to the data I deal with daily, which is non-normalized and has column names that sometimes use special characters. Let’s take a look at the Resource and ResourceFactory for this service in case others need to take this same approach.

While it isn’t ideal to be running raw sql in the Resource, sometimes we don’t have much choice, and I wanted to demonstrate a simple way to get started on the IBM i. That’s it for now. Stay tuned for Apigility + OAuth2 on the IBM i and how to digest these services with Angular2.

Leave a Reply

Your email address will not be published. Required fields are marked *