views:

705

answers:

2

I am trying to use Zend's Gbase library, but I cannot figure out how to do so without actually installing it in the PHP path.

The complication comes from wanting to make a module for Drupal that is not constrained by the server it is installed on, but can access the library by having it installed in a subfolder of the module.

Does anyone know how to do this? I have tried doing an include of Zend's Loader and then loading the classes I want, but this keeps throwing errors. Do I NEED to install the library on the server, or is there a way around this, to only have it used on this application?

This is the code:


require_once 'library/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_Gbase');

I get the folowing messages:

Warning: Zend_Loader::include(Zend/Gdata/Gbase.php) [zend-loader.include]: failed to open stream: No such file or directory in /srv/www/ftp-www/tests/gdata/library/Zend/Loader.php on line 83

Warning: Zend_Loader::include() [function.include]: Failed opening 'Zend/Gdata/Gbase.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /srv/www/ftp-www/tests/gdata/library/Zend/Loader.php on line 83

Warning: Zend_Loader::require_once(Zend/Exception.php) [zend-loader.require-once]: failed to open stream: No such file or directory in /srv/www/ftp-www/tests/gdata/library/Zend/Loader.php on line 87

Fatal error: Zend_Loader::require_once() [function.require]: Failed opening required 'Zend/Exception.php' (include_path='.:/usr/share/php:/usr/share/pear') in /srv/www/ftp-www/tests/gdata/library/Zend/Loader.php on line 87

+5  A: 

What about using set_include_path to configure your include_path, adding to it the directory in which Zend Framework's code is ?

This way, you can have it whereever you want -- whitout having to modify the include_path in the php.ini configuration file.

For instance, something like this might do :

$path = '/PATH_TO_THE_FRAMEWORK/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

Wouldn't that help ?

Pascal MARTIN
Zend suggest to setup path so that the ZF path is in the beginning. Because it takes then less time to find the classes. Most classes are from ZF and few are your own...
Tomáš Fejfar
thanks. That seems to have worked. Simply adding the 'library' to the zend_loader function wasn't enough. Much appreciated. i'd vote up your answer, but I don't have enough 'reputation'
msumme
You're welcome :-) (don't worry about the rep thing ; still, if an answer solved your problem, you should be able to mark is as "accepted" -- you can do that on only one answer per question, though ; so, choose wisely ^^ )
Pascal MARTIN
+2  A: 

You need to specify where to look for the class files. Try:

Zend_Loader::loadClass('Zend_Gdata_Gbase', 'library/')

Or you may want to set the library folder in your php include path

Mark