|
ChartDirector with Zend Framework |
Posted by Robert on Jul-13-2011 23:42 |
|
Hi,
I am in the process of porting my application to th Zend Framework. I previoulsy had ChartDirector runnig fine from a folder in the web root.
I wanted to put the ChartDirector folder in the Library directory of Zend Framework. However when i do this I get an error...
"Error Loading ChartDirector for PHP Extension"
Error Log
Trying to load "phpchartdir520.dll" from the PHP extension directory "/usr/lib/php/modules".
dl(): Unable to load dynamic library '/usr/lib/php/modules/phpchartdir520.dll' - /usr/lib/php/modules/phpchartdir520.dll: cannot open shared object file: No such file or directory
It seems to be looking for the appropriate dll in the wrong directory.
Any help would be appreciated.
Robert |
Re: ChartDirector with Zend Framework |
Posted by Robert on Jul-13-2011 23:44 |
|
forgot to mention. in case you aren't familiar with zend framework. the library folder is above the public web root folder and is therefore not accessible via a browser. i suspect this is where the problem lies. Does ChartDirector need to be in the web root? |
Re: ChartDirector with Zend Framework |
Posted by Peter Kwan on Jul-14-2011 01:40 |
|
Hi Robert,
The directory "/usr/lib/php/modules" is not chosen by ChartDirector. It is chosen by your PHP. Your PHP uses this directory because it is configured to use this directory for PHP extensions (the "extension_dir" configuration in "php.ini").
ChartDirector can be put in any directory you like. Note that if you are using PHP 5.2.5 or above, PHP requires to you put all PHP extensions in the PHP extension directory (not the PHP library directory).
So for your case, there are two methods:
(a) Configure your PHP extension directory to point to the same directory as your PHP library directory, which contains everything in "ChartDirector/lib". You may need to restart Apache after any change to "php.ini".
or
(b) Copy everything in "ChartDirector/lib" to your currently PHP extension directory in "/usr/lib/php/modules".
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector with Zend Framework |
Posted by Robert on Jul-14-2011 03:46 |
|
Hi Peter,
Thanks for the reply. I'm a little confused though.
Today I upgraded the version of PHP to 5.2.17 and moved ChartDirector to a directory outside of the main web root. As mentioned prior to these changes it was working fine.
I didn't check to see if it was working in between the two changes above.
So, where would it have been picking up the extension directory from, prior to the changes above and when it was working (ChartDirector was just in the web root)?
Ideally I would like to keep ChartDirector in its new home as it is stored with various other third party products. Does this m,ean I need to update php's extension dir? will this not have knock on consequences?
Robert |
Re: ChartDirector with Zend Framework |
Posted by Peter Kwan on Jul-14-2011 16:16 |
|
Hi Robert,
PHP 5.2.4 or below supports installing PHP extension in any directory.
PHP 5.2.5 or above has removed the above feature. All PHP extensions must be in the PHP extension directory.
For more details, you may refer to your PHP documentation. (Only each PHP version, there are release notes that mention what has changed.)
So if you are using PHP 5.2.4 or below, you can put the ChartDirector extension in any directory. If you are using PHP 5.2.5 or above, you must put the ChartDirector extension in the PHP extension directory.
If you have third party products, all third party PHP extensions must also be put in the PHP extension directory. So ChartDirector should already been in the same directory as any of your third party PHP extensions.
Are your third party products PHP extensions or PHP libraries? PHP extensions must be put in the PHP extension directory, while PHP libraries can be put anywhere you like. PHP libraries are PHP code that implements various functions. However, because the PHP language is very limited, many things cannot be done in PHP practically (eg. database drivers, computer graphics, etc). For these things, PHP extensions need to be used, which are written in C/C++, compiled into shared objects and loaded into the PHP interpreter.
ChartDirector includes both a PHP library "phpchartdir.php" that can be put anywhere, and a PHP extension (the shared objects). PHP 5.2.4 allows you to put the PHP extension in any directory, while PHP 5.2.5 or above mandates that all PHP extensions must be in the PHP extension directory.
So in summary, the ChartDirector PHP extension should be installed in the same directory as all your third party PHP extensions, which should be the PHP extension directory. You can put the ChartDirector PHP library (phpchartdir.php) in the same directory as your third party PHP library too, or any directory in your PHP include path. If you want to change the PHP extension directory, you may modify "extension_dir" in "php.ini".
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector with Zend Framework |
Posted by Robert on Jul-14-2011 21:19 |
|
Hi Peter,
Thanks for the reply. I need to tidy up some of my terminology!
I mean library not extension. So I am using ChartDirector as a simple library not an extension. I have made no changes to php.ini for ChartDirector to be treated as an extension.
So...
I am using a version of PHP that means I can put ChartDirector where I like.
In my scripts I do a require_once on phpchartdir.php which is located fine. This checks the version of PHP I am using and tries to include the appropriate *.dll file.
Should it be doing this or should it only do this if it is being treated as an extension?
Why is it picking up the extensions directory from PHP and not using its own directory?
Can I hard-code the directory to use?
Thanks again,
Robert |
Re: ChartDirector with Zend Framework |
Posted by Peter Kwan on Jul-15-2011 00:06 |
|
Hi Robert,
ChartDirector is a PHP extension.
Whether something is a PHP extension or not does not depend on how you use it. For example, the PHP MySQL driver is a PHP extension. No matter how you use it, it is still a PHP extension, because it is designed as a PHP extension. Similarly, ChartDirector is a PHP extension (although it also includes a PHP library "phpchatdir.php").
The ChartDirector PHP extension and PHP library must be used together. If you do not load the ChartDirctor PHP extension using extension statements in "php.ini" and just use the ChartDirector PHP library, the ChartDirector PHP library will automatically load the ChartDirector PHP extension.
In PHP 5.2.4 or below, PHP supports loading from any directory. ChartDirector will then try to load the ChartDirector PHP extension from the same directory as "phpchartdir.php".
In PHP 5.2.5 or above, PHP does not allow program code to specify any extension directory at all. If the code specifies any extension directory, PHP will stop with a fatal error. The code can only specify the file name. The directory to use is specified by you, using the extension_dir in "php.ini".
So in brief:
(a) ChartDirector does not pick up any directory from PHP. It just passes the filename to PHP. PHP automatically chooses the directory based on your PHP configuration ("php.ini").
(b) ChartDirector does not use its own directory because you are using PHP 5.2.5 or above. PHP 5.2.5 does not allow specifying any directory. If you use PHP 5.2.4 or below, ChartDirector will try to load from its own directory.
(c) You can hard-code the directory to use. According to PHP documentation, the method is to enter the directory name in the extension_dir setting in "php.ini".
For more details, you may consider to refer to the PHP documentation.
Hope this can help.
Regards
Peter Kwan |
Re: ChartDirector with Zend Framework |
Posted by Robert on Jul-15-2011 17:14 |
|
Hi Peter,
Thanks for all the help. I'm still having issues but will find a way around it based on your suggestions.
As a test I moved ChartDirector back to its original directory and I am still getting the same issues. This is the bit that puzzles me. I was using ChartDirector with an earlier version of PHP 5.2. I just dropped it in my web root and it worked straight away. It seems my updated version of PHP is the problem to be honest. Its only 5.2.17 but is causing issues.
Anyway, I'll either put ChartDirector in the exnetsion dir or change the extension dir.
Robert |
|