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 System | File Name |
---|
Windows | chartdir_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 are using Windows, you may use Winzip or similar tools to unzip the ChartDirector distribution.
- If you are using Linux, FreeBSD, Mac OS X or Solaris, first copy the ChartDirector distribution to your web server HTML directory, then change to your web server HTML directory, and issue the following commands:
gunzip [chartdir_file_name].tar.gz
tar xvf [chartdir_file_name].tar
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.
- PHP working as a multi-threaded web server module does not support dynamic loading of extensions (eg. "Server API = Apache" and "Thread Safety = enabled"). From experience, PHP/Apache on Windows is likely to be multi-threaded and is affected. PHP on Linux, FreeBSD, Mac OS X and Solaris is likely to be single-threaded and is not affected.
- System administrators may disable dynamic loading of extensions by setting "enable_dl = No" or "safe_mode = Yes" in php.ini.
- On Windows, PHP requires the extension files to be in the same logical drive as the PHP extension directory. If your web server HTML directory is in a different logical drive from your PHP extension directory, you would need to copy everything in "ChartDirector/lib" to the PHP extension directory.
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:
- Copy everything in "ChartDirector/lib" (including the fonts subdirectory in Linux, FreeBSD and Solaris versions) to the PHP extension directory.
Please ensure you know where is the
PHP extension directory. From experience, the vast majority of issues are due to confusion on where is the PHP extension directory.
- Enter the line "
extension=phpchartdir###.dll
" in php.ini, where "phpchartdir###.dll
" is a file chosen using the table below. The file depends on your PHP version, operating system, and PHP thread-safety settings. You may use phpinfo to find out these settings. From experience, the majority of PHP systems on Linux, FreeBSD, Mac OSX and Solaris are not thread-safe.
PHP Version | Windows | Linux, FreeBSD, Mac OS X, Solaris |
Not Thread-Safe | Thread-Safe |
4.0.4pl1 | phpchartdir404.dll | phpchartdir404.dll | phpchartdir404mt.dll |
4.0.5 - 4.0.6 | phpchartdir405.dll | phpchartdir405.dll | phpchartdir405mt.dll |
4.1.0 - 4.2.0 | phpchartdir410.dll | phpchartdir410.dll | phpchartdir410mt.dll |
4.2.1 - 4.x.x | phpchartdir421.dll | phpchartdir421.dll | phpchartdir421mt.dll |
5.0.0 - 5.0.2 | phpchartdir500.dll | phpchartdir500.dll | phpchartdir500mt.dll |
5.0.3 - 5.0.5 | phpchartdir503.dll | phpchartdir503.dll | phpchartdir503mt.dll |
5.1.0 or above | phpchartdir510.dll | phpchartdir510.dll | phpchartdir510mt.dll |
Please make sure you know where is your active
php.ini. If in doubt, use
phpinfo to find out.
- Restart your web server. PHP only reads php.ini during initialization, so you would need to restart your web server to have the changes 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
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.
- Create a one-line ASCII file using Notepad or other text editor, and put the license code in that line. The whole file should contain only the license code. Name that file "chartdir.lic" and put the file in the same directory as the active "libchartdir.so" (for Linux, FreeBSD, Mac OS X and Solaris) or "chartdir.dll" (for Windows), which should be in the "ChartDirector/lib" directory or your PHP extension directory.
If the license file appears to have no effect (does not disable the yellow banner line), and you are running on a web server environment, please make sure the web server "anonymous user" has read access to the "chartdir.lic" file. You may copy the file "ChartDirector/phpdemo/cdinfo.php" to your web server and access it using a browser. It will display a diagnostic page explaining why the license cannot be loaded.
Make sure your license file is called "chartdir.lic". In particular, Notepad may automatically append ".txt" to the file name when creating a new file. So even if the file is saved as "chartdir.lic", it may end up as "chartdir.lic.txt". If this is the case, please rename the file back to "chartdir.lic".
- An alternative method is to hard code the license key into the source code by using the setLicenseCode API. This method is recommended if your are redistributing ChartDirector, because your customer will then be unable to see the license key (unless your software is open source).
setLicenseCode(".....your-license-key.....");
© 2006 Advanced Software Engineering Limited. All rights reserved.