ChartDirector Ver 4.1 (PHP Edition Edition)

Installing ChartDirector for PHP


PHP Version Compatibility

ChartDirector for PHP requires at least PHP 4.0.4pl1, and has been tested up to PHP 5.1.4 (the latest PHP release as of the date of this document).

Note: ChartDirector for PHP on Mac OS X only supports PHP 4.2.1 or above.

Extracting the ChartDirector Distribution

ChartDirector for PHP is released on Windows, Linux, FreeBSD, Mac OS X and Solaris. Before we start installation, you may want to verify the ChartDirector distribution you have downloaded is for your operating system by using the table below. If you do not know what is your operating system (eg. you are using a remote host), you may use phpinfo to find out.

Operating SystemFile Name
Windowschartdir_php_win32.zip
Linux (i386)chartdir_php_linux.tar.gz
Linux (x86_64 - 64bit OS)chartdir_php_linux_64.tar.gz
FreeBSD (i386)chartdir_php_freebsd.tar.gz
Mac OS X (Power PC/Intel)chartdir_php_mac.tar.gz
Solaris (Sparc)chartdir_php_sunos.tar.gz

To install ChartDirector for PHP, extract the files from the ChartDirector distribution to your web server HTML directory (or any directory that allow PHP scripts to execute):

If you cannot access the command prompt (eg. you are using a remote host with no telnet access), you may extract ChartDirector on a local machine first (eg. using Winzip), then upload the files to your host using FTP.

If the connection to your remote host is not fast, you may consider to upload only the "ChartDirector/phpdemo" and "ChartDirector/lib" subdirectories, while keeping the documentation "ChartDirector/doc" in your local machine.

Note for FreeBSD Users : If you are using the FreeBSD Ver 5.x or above, please ensure your system is configured to be compatible with FreeBSD 4.x (with compat4x installed). You may use "pkgadd -r compat4x-i386" to install compat4x if it is not already installed.

Verifying Your PHP Configuration

The core of ChartDirector is implemented as a PHP extension. If your PHP system supports dynamic loading of extensions, ChartDirector will automatically load the ChartDirector PHP extension when needed. Therefore, no PHP configuration is required to use ChartDirector.

However, some PHP systems may have dynamic loading of extensions disabled (eg. for security reasons) or restricted. In these cases, you may put an extension statement in php.ini to load ChartDirector.

You may use phpinfo to find out if the your PHP system belongs to one of the above types. Another method is to simply try the ChartDirector for PHP sample scripts to see if they work.

To try the sample scripts, use the following URL to view the sample scripts index page (note: the exact URL depends on where you have extracted ChartDirector to).

http://aaa.bbb.ccc.ddd/ChartDirector/phpdemo/index.php

In the sample scripts index page, there is a "check installation" link on the right window. If it returns the ChartDirector version along with some other information, then dynamic loading of ChartDirector is successful.

On the other hand, if it returns an error message, please refer to Trouble-Shooting ChartDirector for PHP Installation for instructions on how to resolve the problem. Note that messages in the "Boot Log" or the "Font Loading Test" are informational only and are not error messages.

Use Extension Statement in php.ini to Load ChartDirector

You need to use extension statement to load ChartDirector if your PHP does not support dynamic loading of extensions.

If your PHP supports dynamic loading of extensions, using extension statement is optional and may improve performance. It is because by using extension statement, instead of dynamically loading ChartDirector everytime when it is needed, PHP will just pre-load it once during initialization.

To use extension statement in php.ini to load ChartDirector:

Running ChartDirector Sample Scripts

ChartDirector for PHP comes with a number of sample PHP scripts under the "ChartDirector/phpdemo" directory. They are good examples and tutorials on how to use ChartDirector.

To try the sample scripts, use the following URL to view the sample scripts index page (note: the exact URL depends on where you have extracted ChartDirector to).

http://aaa.bbb.ccc.ddd/ChartDirector/phpdemo/index.php

If ChartDirector is installed correctly, you should see sample charts being generated by the sample PHP programs as you click through the links in the "index.php" page.

If for some reason, you cannot see the charts, please refer to Trouble-Shooting ChartDirector for PHP Installation for trouble-shooting instructions.

Using ChartDirector for PHP in Your Own Scripts

To use ChartDirector, please include the ChartDirector script "phpchartdir.php" in your own script using the PHP "require_once" statement. For example, all ChartDirector sample scripts use the following line to include "phpchartdir.php":

require_once("../lib/phpchartdir.php");

For your own scripts, you may copy everything in "ChartDirector/lib" (including the fonts subdirectory in Linux, FreeBSD, and Solaris versions) to your script directory. You may then use the following line to include "phpchartdir.php":

require_once("phpchartdir.php");

Another option is to copy everything in "ChartDirector/lib" to your PHP extension directory (you may have already done that if you are using extension statement to load ChartDirector). In this case, you just need to copy one file "phpchartdir.php" to your script directory. It will search for the other ChartDirector files in the PHP extension directory.

Note that require_once assume the path is a file system path. If you use an absolute path name (eg. a path name starting with a slash "/"), the root is the file system root directory, not the web server root directory.

Installing the ChartDirector License

If you have purchased a license to use ChartDirector, you should have a license code delivered to your via email and postal mail.

If your license key is for upgrading from a previous version of ChartDirector, you need to append the upgrade license key to the previous version license key, and use the combined license key.

There are two alternative methods to install the license key.