ChartDirector 5.1 (PHP Edition)

Installing ChartDirector for PHP

PHP Version Compatibility

ChartDirector for PHP requires at least PHP 4.0.4pl1. ChartDirector has been tested up to PHP 5.5, which is the latest PHP release as of the writing of this document.

Note: ChartDirector for PHP on Mac OS X, Solaris (x86), Linux (x86_64) and FreeBSD (AMD64) only supports PHP 4.2.1 or above.

Extracting the ChartDirector Distribution

ChartDirector for PHP is supported on Windows, Linux, FreeBSD, Mac OS X and Solaris. Before installation, please verify the ChartDirector distribution you have downloaded is for the operating system edition of PHP you are using. (See table below.) If you are not sure the type of PHP you are using, you may use phpinfo to find out.

Note for 64-bit Windows: As of the writing of this document, it is common to use 32-bit PHP on 64-bit Windows. If you are using 32-bit Windows PHP, you should use the Windows (32-bit) edition of "ChartDirector for PHP", even if the operating system is Windows 64-bit.

Operating SystemFile Name
Windows (32-bit)
Windows (64-bit)
Linux (i386/i686)chartdir_php_linux.tar.gz
Linux (x86_64 - 64bit OS)chartdir_php_linux_64.tar.gz
FreeBSD (i386)chartdir_php_freebsd.tar.gz
FreeBSD (AMD64)chartdir_php_freebsd_64.tar.gz
Mac OS X (Power PC/Intel)chartdir_php_mac.tar.gz
Solaris (Sparc)chartdir_php_sunos.tar.gz
Solaris (x86)chartdir_php_sunos_86.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 or ssh access), you may extract ChartDirector to a local machine first, then upload the files to your host using FTP. If the connection to your remote host is not fast, you may upload only the "ChartDirector/phpdemo" and "ChartDirector/lib" subdirectories, and keep the "ChartDirector/doc" (containing the documentation) in your local machine.

Installing ChartDirector for PHP

ChartDirector for PHP is implemented as a PHP extension in "ChartDirector/lib". There is also an include file "phpchartdir.php", which interfaces PHP scripts with ChartDirector PHP extension.

Modern versions of PHP (5.3.0 or above) requires all PHP extensions to be copied to the PHP extension directory, and be loaded using extension statements in the PHP configuration file php.ini.

Older versions of PHP (before PHP 5.3.0) may allow PHP extensions to be loaded dynamically without using "php.ini", in which case "phpchartdir.php" will try to load the ChartDirector extension from the PHP extension directory automatically. PHP 5.2.4 or earlier may not require copying PHP extensions to the PHP extension directory, in which case "phpchartdir.php" will try to load the ChartDirector extension from both the PHP extension directory and the directory that contains "phpchartdir.php".

The following installation method is based on the more restrictive requirements of PHP 5.3.0 or above, which also works on all earlier PHP versions.

If you cannot modify the "php.ini" or add files to the PHP extension directory (eg. due to limited access rights), you may refer to Considerations for Shared Hosting for some suggestions.

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).


In the sample scripts index page, there is a "check installation" link in the right window. Please click on that link. If it displays the ChartDirector version with some other information, it can be confirmed that ChartDirector is installed successfully. Note that messages in the "Boot Log" or the "Font Loading Test" are informational only and are not error messages.

After confirming that ChartDirector is installed successfully, you may click the links in the left window to see the sample charts.

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":


Note that require_once assumes the path is a file system path, not a URL. If you use an absolute path name (eg. a path name starting with a slash "/"), the root is the root of the hard disk, not the root of the web document directory.

Installing the ChartDirector License

If you have purchased a license to use ChartDirector, you should have a license key 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.