Migrating applications from PHP 4 to Zend Core 2.5 with support for IBM Informix on Linux Platform.

Introduction

There are many business web applications written in PHP4 that use the Informix module for data access. PHP4 is no longer supported and as a result will not be issued any more fixes or releases. Since version 5.2, the Informix module is no longer available for the PDO module.

In this article I’ll to describe how to compile and install the Informix module on the Zend Core 2.5 (PHP 5.2.6)

Requirements

Assuming that the operating system available to us both has Linux Kernel 2.6, you must install and configure a set of software elements that will be necessary to complete the compilation and installation of the module are Informix. Following components:

  • Development tools (gcc, make, automake, bison, etc …)
  • Informix CSDK Version 2.90 or 3.0
  • Zend Core 2.5 for Linux 2.6

Preparing PHP environment

For the installation of PHP modules that are not officially supported by Zend Core platform is necessary to build the modules you want by using the source tree used by the Zend Core. The version 2.5 of Zend Core was created with version 5.2.6 of PHP found at www.php.net. The source tree must be built with the same settings used to compile the build of Zend Core, to obtain this information you will need a script that uses the PHP function phpinfo() or use the command php -i, in Figure 1 and Figure 2 are illustrated examples.

Figure 1. Page phpinfo () that shows the command to configure Zend Core

Figure 2 Example of command php -i shows that the command to configure Zend Core

Now we can proceed to build the PHP source tree using the same configure command of Zend Core. After running the configure command proceed to make, should not be run the command make install.

Building and installing the module Informix

The Informix module is not directly available on version 5.2.6 of PHP, so download the source code of the module directly from the site http://pecl.php.net/package/informix. The tarball of the module is not available on the site; however, it does not matter, we’ll make a checkout of the sources of the module from CVS reposistory. To do this use the following command:

cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pecl/informix


Figura 3 Checkout Informix Module from CVS Repository

Now that we have the sources of Informix module, we need to copy the source tree of PHP 5.2.6 into the modules directory (eg / home/amusarra/php-5.2.6/ext), then proceed with the build :

amusarra@linux-zoao:~/php-5.2.6/ext/informix> /usr/local/Zend/Core/bin/phpize --with-php-config=/usr/local/Zend/Core/bin/php-config
amusarra@linux-zoao:~/php-5.2.6/ext/informix> ./configure --with-php-config=/usr/local/Zend/Core/bin/php-config

Before continuing with the make of the Informix Module, you must edit the Makefile to ensure that the module is linked with Informix library checkapi.o, otherwise the use of the module will produce the error: undefined symbol: ifx_checkAPI.

Inside Makefile should replace the value of the directive INFORMIX_SHARED_LIBADD with:

-Wl,-rpath,/opt/IBM/informix/lib/esql -L/opt/IBM/informix/lib/esql -Wl,-rpath,/opt/IBM/informix/lib -L/opt/IBM/informix/lib -lifsql -lifasf -lifgen -lifos -lifgls -ldl -lcrypt /opt/IBM/informix/lib/esql/checkapi.o -lifglx

After editing the Makefile to proceed with the build and installation of the Informix module:

linux-zoao:/home/amusarra/php-5.2.6/ext/informix # make && make install

The module Informix (informix.so) will be installed in /usr/local/Zend/Core/lib/php/20060613/. We could verify the correct link to the library Informix checkapi.o just using the nm command, you should get a result like this:

linux-zoao:/home/amusarra/php-5.2.6/ext/informix # nm /usr/local/Zend/Core/lib/php/20060613/informix.so | grep ifx_checkAPI
0000ba24 T ifx_checkAPI

Activation and test module Informix

You can activate the module in two ways: use the Zend Core Web Interface or edit the configuration file (in /usr/local/Zend/Core/etc/) php.ini. By choosing the second option just add the extensions in the line:

extension=informix.so

Restart the http service and Informix module is ready for use. In Figure 4 an extract from phpinfo () that illustrates the configuration of the Informix module just installed.

Figura 4 Informix Module configuration

Let’s see a simple example PHP script that uses the Informix module:

<?php
 	$conn_id = ifx_connect ("sysmaster@francisco_on", "amusarra", "amusarra");
 	ifx_textasvarchar(1);      // use "text mode" for blobs
 	$res_id = ifx_query("select * from informix.sysenv", $conn_id);
 
 	if (! $res_id) {
 		printf("Can't select sysenv : %s\n<br />%s<br />\n", ifx_error(), ifx_errormsg());
 		ifx_close($conn_id);
 		die;
 	} 
	
	ifx_htmltbl_result($res_id, "border=\"1\"");
 	ifx_free_result($res_id);
 	ifx_close($conn_id);
 ?>   

Figure 5 Result of the script shown above