ChartDirector Ver 5.0 (PHP 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.3.0 (the latest PHP release as of the date of this document).

Note: ChartDirector for PHP on Mac OS X, Solaris (x86) and FreeBSD (AMD64) 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
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 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.

Verifying Your PHP Configuration

ChartDirector for PHP is implemented as a PHP extension, which consists of everything in "ChartDirector/lib". The method used by a PHP system to load an extension differs depending on the PHP system is configured.

  1. Some PHP systems can dynamically load extensions from the web document directory. If you are using this type of PHP system, no further installation step is necessary. You may proceed to Running ChartDirector Sample Scripts.

  2. Some PHP systems can only dynamically load extensions from the PHP extension directory. If you are using this type of PHP system, you would need to copy ChartDirector to the PHP extension directory.

  3. Some PHP systems cannot dynamically load any extension at all. If you are using this type of PHP system, you would need to copy ChartDirector to the PHP extension directory, and use extension statement to load ChartDirector.

You may use phpinfo to examine your PHP configuration, so as to determine the type of PHP you using. For your convenience, the ChartDirector distribution includes a phpinfo page at (note: the exact URL depends on where you have extracted ChartDirector to):

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

If your PHP system has any of the following characteristics, it is of type (3) mentioned above, that is, it cannot dynamically load any extension.

If your PHP system has any of the following characteristics, it is of type (2) mentioned above. It can only dynamically load extensions from the PHP extension directory.

If your PHP system does not have any of the above characteristics, it is likely to be of type (1) mentioned above. It can load extensions from the web document directory.

Copying ChartDirector to the PHP Extension Directory

Note: This step is only necessary if your PHP cannot dynamically load extensions from the web document directory. Otherwise this step is optional. See Verifying Your PHP Configuration for details.

To copy ChartDirector to the PHP extension directory, please copy everything in "ChartDirector/lib" (including the fonts subdirectory in Linux, FreeBSD and Solaris versions of ChartDirector) to the PHP extension directory.

Using Extension Statement to Load ChartDirector

Note: This step is only necessary if your PHP cannot dynamically load any extension. Otherwise this step is optional. See Verifying Your PHP Configuration for details.

Using extension statements may improve performance for PHP that uses SAPI. It is because instead of dynamically loading an extension on demand, PHP will pre-load it once during initialization. So it is not uncommon for installations to use extension statements, even if it is not mandatory.

To use extension statement to load ChartDirector, please ensure you have already copied ChartDirector to the PHP extension directory. Then add the following line to your php.ini.

extension=phpchartdir###.dll

In the above, the "phpchartdir###.dll" depends on your PHP version, operating system, and PHP thread safety settings. Please use the following table to determine the "phpchartdir###.dll" to use:

PHP VersionWindowsLinux, FreeBSD, Mac OS X, Solaris
Non-Thread-SafeThread-SafeNon-Thread-SafeThread-Safe
4.0.4pl1N/Aphpchartdir404.dllphpchartdir404.dllphpchartdir404mt.dll
4.0.5 - 4.0.6N/Aphpchartdir405.dllphpchartdir405.dllphpchartdir405mt.dll
4.1.0 - 4.2.0N/Aphpchartdir410.dllphpchartdir410.dllphpchartdir410mt.dll
4.2.1 - 4.x.xN/Aphpchartdir421.dllphpchartdir421.dllphpchartdir421mt.dll
5.0.0 - 5.0.2N/Aphpchartdir500.dllphpchartdir500.dllphpchartdir500mt.dll
5.0.3 - 5.0.5N/Aphpchartdir503.dllphpchartdir503.dllphpchartdir503mt.dll
5.1.xN/Aphpchartdir510.dllphpchartdir510.dllphpchartdir510mt.dll
5.2.xphpchartdir520nts.dllphpchartdir520.dllphpchartdir520.dllphpchartdir520mt.dll
5.3.0 or abovephpchartdir530nts.dllphpchartdir530.dllphpchartdir530.dllphpchartdir530mt.dll

If your PHP "Server API" is not "CGI", you would need to restart you web server for any modification to "php.ini" to take effect.

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

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.

If the "check installation" link 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.

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

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");

If the ChartDirector PHP extension has been copied to the PHP extension directory, you just need to copy one file "phpchartdir.php" to your script directory (instead of everything in "ChartDirector/lib").

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.