Composer on the IBM i... or anywhere

What is composer?

If you are not familiar with composer, I would strongly encourage you to read this:

It allows you to declare your dependecies in a JSON file, and installs/updates them for you.


Say I'm using Zend Framework 2 in my application. My application depends on Zend Framework 2. Zend Framework 2 might depend on something else being installed. Once you define that dependency in the Composer.JSON file, and run the "composer install" command, Composer will download what you will need to the vendor folder.


Composer allows you to choose bits and pieces from various frameworks or libaries. It creates an autoloader for you so that you can point your application to it's autoloader, and you are set to go. It really saves you time and headaches once you get used to using it.

How? (IBM i specific)

We will be using QP2TERM by running CALL QP2TERM from the command line.

Steps In Brief:

1. Add PHP to classpath

2. Run Composer installer

3. Copy it to php bin library

4. Use it!

Step 1 - Add PHP to classpath

You can simply run the following commands on the QP2TERM command line (you need to do this each time you go into QP2TERM):

$ PATH=$PATH:/usr/local/zendsvr6/bin

$ LIBPATH=$LIBPATH:/usr/local/zendsvr6/bin

$ export PATH

$ export LIBPATH

Or you can create/modify a file called .profile with those exact commands in /home/YOURUSERPROFILEHERE/

See this article:

I find if I use EDTF to create the file, it creates it as CCSID 37. If I create it in notepad and FTP it to the IFS, it will create it in CCSID 819, which is the correct CCSID

Step 2 - Run composer installer

Here are the installation instructions:


$ php -r "readfile('');" > composer-setup.php

(on one system, it wouldn't allow me to run https, so I just changed the URL to http)

$ php composer-setup.php

$ php -r "unlink('composer-setup.php');"

Step 3 - Copy it to the PHP library

$ mv composer.phar /usr/local/zendsvr6/bin

Step 4 - Use it!

Create a composer.json in your folder. We'll take a look at that in a subsequent post.

Run composer install!

$ composer.phar install

Watch your folders be filled with dependencies :)

Please contact me if you have any questions.

Featured Posts
Recent Posts
Search By Tags
No tags yet.
  • Google+ Social Icon
  • Facebook Social Icon
  • LinkedIn Social Icon
  • Twitter Social Icon

Contact Me

Tel: 250-721-0817

  • LinkedIn Social Icon
  • Twitter Social Icon
This site was designed with the
website builder. Create your website today.
Start Now