the easiest way is probably to let the autoloader of eZ Publish do the job. Active your extension and regenerate the autoload array with the following command line :
php bin/php/ezpgenerateautoloads.php
so your class will be automatically included when needed without having to define a specific Autoloader class.
If your component uses one or more Zend components, you'll also probably need to alter the include_path as there are sometimes explicit include statements in Zend code or include of PHP files not containing a class definition. You can do that in your own code before using your component or in config.php file in the eZ Publish root. I use the former in autostatus extension when using Zend_Service_Twitter component.
Or you can set it up in config.php, have a look in config.php-RECOMMENDED file, it includes an example in the bottom.
This means the users of your extensions would need to set this up as part of the extension installation procedure, but should be simple if you provide examples in your installation doc.
It should work in 4.0 too. In fact, ezpgenerateautoload.php looks for class definitions in all PHP files of each extension.
Btw, I've just discovered that from the 4.1, you can also define and register your own autoload function and register it in config.php but as said by André, it's less handy, if you want to distribute your extension.
It should work in 4.0 too. In fact, ezpgenerateautoload.php looks for class definitions in all PHP files of each extension.
Btw, I've just discovered that from the 4.1, you can also define and register your own autoload function and register it in config.php but as said by André, it's less handy, if you want to distribute your extension.
Cheers
Works like a charm with ezpgenerateautoload.php !! some ezp Awesomeness ^_^
It should work in 4.0 too. In fact, ezpgenerateautoload.php looks for class definitions in all PHP files of each extension.
Btw, I've just discovered that from the 4.1, you can also define and register your own autoload function and register it in config.php but as said by André, it's less handy, if you want to distribute your extension.
Cheers
This means:
// Append your directory to the include path
set_include_path( get_include_path() . PATH_SEPARATOR . 'extensions/xyz/library/');
// Just create the new object it, or do a spl_autoload_call( $className );
// to look for the class before you try to initiate it.
$object = new $className();
You must be logged in to post messages in this topic!