Using the IMu API
The IMu API source code bundle for version 2.0 (or higher) is required to develop an IMu-based application. This bundle contains all the classes that make up the IMu PHP API. Contact Axiell Support for access to the IMu API bundles.
To build PHP web-based applications (the most common use of the IMu PHP API), the source code bundle must be extracted on the web server machine and be accessible by the web server.
In order to use the IMu PHP API, include IMu.php
in the PHP code.
For example, if the IMu API source code is installed in the directory
/usr/local/lib/imu
the following line would be added to the PHP
code:
The IMu.php
file defines the IMu
class. This class includes static
members which contain information about the IMu installation. The class
includes:
IMu::$lib
- the path to the IMu PHP API files.IMu::VERSION
- the version of this IMu release.
The $lib
member should also be used to simplify the requiring of other IMu
library files, for example:
<?php require_once IMu::$lib . '/Session.php'; ?>
Test Program
Building this very simple IMu-based web page is a good test of whether the development environment has been set up properly for using IMu:
<?php require_once '/usr/local/lib/imu/IMu.php'; printf('IMu version %s', IMu::VERSION); exit(0); ?>
Exceptions
Many of the methods in the IMu library objects throw an exception when an error
occurs. For this reason, code that uses IMu library objects should be
surrounded with a try
/ catch
block.
The following code is a basic template for writing PHP programs that use the IMu library:
<?php require_once '/usr/local/lib/imu/IMu.php'; // ⋯try { /* Create and use IMu objects * ⋯ */ }catch (Exception $e) { /* Handle or report error * ⋯ */ } ?>
Most IMu exceptions throw an IMuException
object. The IMuException
class is a subclass of the standard PHP Exception
. In many cases your
code can simply catch the standard Exception
(as in this template). If more
information is required about the exact IMuException
thrown, see Exceptions.
Note: Many of the examples that follow assume that code fragments have been surrounded with code structured in this way.