ctors.net
Blog tvlooy

Symfony2 on IBM i

IBM i, Symfony2 | December 02, 2012

There is a screencast on YouTube for this post.

It’s no secret that I’m a fan of the IBM i platform. It’s also no secret that I am a Symfony2 user. Today I combined these two and installed a Symfony2 project on IBM i.

Your IBM i

I don’t have access to a recent IBM i machine to play with. But IBM has a Virtual Loaner Program (VLP) where you can basically have access to your own LPAR. Downsides are that you have to become a PartnerWorld member (which takes a few days). Also, the time on your machine is limited to 14 days (per timeslot). And, you have to VPN into the IBM VLP network to access your machine. Not meant for public demo’s.

On the other hand, PartnerWorld membership is completely free. And, you can automatically save your LPAR as an image on the VLP SAN. Later, you can request a new 14 day timeslot and start from the saved LPAR. Plus, you have access to the newest hardware (POWER 7) and software (IBM i 7.1).

Connection to VLP

The VLP provides good documentation on how to set up the connection. As Linux user, I use the Cisco AnyConnect VPN client to access the VLP network. The VLP links to the installer of this client on the VPN access webpage. After installation, it’s a matter of running "/opt/cisco/anyconnect/bin/vpnui" and entering your credentials.

IBM i access

As a Linux user, download and extract the tn5250j client. Then run "java -jar tn5250j.jar" to start the program.

You can also just SSH into your machine with the QSECOFR user. You will then be in the PASE environment. If you log in with SSH, you will have a crappy QSH shell. We will solve this later.

PHP installation

As you will see in "GO LICPGM" IBM enables Zend Server 5.0 on the VLP machines, this includes PHP. Unfortunately, it’s a little outdated. From the bash shell, run:

# /usr/local/ZendSvr/bin/php-cli -v PHP 5.2.11 (cli) (built: Jan 3 2010 15:53:33)

Symfony2 requires at least 5.3.3. So we will install a new Zend Server 5.6 with PHP 5.3.8 our own. First just remove the old Zend Server with:

DLTLICPGM LICPGM(2ZSVRPI)

Now, download Zend Server for IBM i from the Zend website and extact the zip file. Zend provides excellent instructions on how to install and use Zend Server for IBM i. They have a PDF on their website that covers Zend Server installation, MySQL installation and so on. Create a SAVF *FILE object on the server with "CRTSAVF QGPL/ZSVRSAVF". Next FTP the file from your machine to the IBM i with the FTP command "put zsvrsavf.savf qgpl/zsvrsavf". Don’t forget to use binary mode!

Now, you can restore the licensed program with the command:

SBMJOB CMD(RSTLICPGM LICPGM(2ZSVRPI) DEV(*SAVF) SAVF(QGPL/ZSVRSAVF))

Wait until the program is completely installed (job will display a message). Check with "GO LICPGM" that the Zend Server licensed program is *INSTALLED.

Now, go to "GO ZENDSVR/ZSMENU" and start the Zend Server subsystem and the Apache processes. You will now have access to the webserver on port 10088. You can run the Zend demo applications there if you like.

MySQL

Above, we installed Zend Server non-interactively. This means that MySQL will not be installed. You can go to "GO ZENDSVR/ZSMENU" and choose MySQL. You can then install MySQL too. Zend Server has PhpMyAdmin enabled, so if you install MySQL you can just use PMA to manage the installation.

Symfony2

In order to install Symfony2, you need Composer. Download the phar file on your machine and copy it to the IBM i (SCP or FTP).

Symfony2 will need to download some dependencies from GitHub. This means that you will need Git. IBM i has a Portable Application Solutions Environment (PASE). This is basically an environment where you can install and run AIX binaries.

The website of young i professionals provides the AIX binaries "rpm" (rpm.rte), "wget" (wget-1.9.1-1.aix5.1.ppc.rpm) and a file "setup.sh" to install these two.

Then, you can download "wwwinstallgit.sh" and install all kinds of other AIX binaries on your IBM i machine (this uses the previously installed rpm and wget). Install git with the command:

./wwwinstallgit.sh --package=git

If you want more useful things, run:

./wwwinstallgit.sh --package=all

For example, this installs bash so you can get out of your crappy QSH. Just run "bash" to switch to good old bash.

The document root of the webserver is at "/www/zendsvr/htdocs". Go there and run the commands:

# alias composer="/usr/local/ZendSvr/bin/php-cli /home/qsecofr/composer.phar" # composer create-project symfony/framework-standard-edition Symfony2 2.1.4

You will now have a Symfony2 project running on your IBM i.

I mounted the IBM i QOpenSys filesystem over SSH from my Linux machine and created some files with Sublime Text 2. I also generated an entity from the commandline on the IBM i and then run "app/console doctrine:schema:update". All seems to work just fine.

Conclusion

It was fun doing this. But this post is not meant to be a real how-to. The instructions are too basic for that.