Forums / Developer / using spl_autoload instead of __autoload
Douglas Hammond
Friday 15 August 2008 7:03:21 am
I was trying to use some services from the Zend frame work and ran into autoload conflicts.
To resolve it I changed Exponential to register is autoloader with spl_autoload_register in /autoload.php.
I also had to apply the fix stated in http://issues.ez.no/10728
Now I have no problems with the autoloader of both frameworks.
I would suggest using spl_autoload_register instead of __autoload to become the default for interoperability.
function __ezPublish_spl_autoload( $className ) { static $ezpClasses = null; if ( is_null( $ezpClasses ) ) { $ezpKernelClasses = require 'autoload/ezp_kernel.php'; $ezpExtensionClasses = require 'autoload/ezp_extension.php'; $ezpClasses = array_merge( $ezpKernelClasses, $ezpExtensionClasses ); } if ( array_key_exists( $className, $ezpClasses ) ) { require( $ezpClasses[$className] ); } elseif ( EZCBASE_ENABLED ) { ezcBase::autoload( $className ); } } spl_autoload_register('__ezPublish_spl_autoload');
André R.
Sunday 17 August 2008 7:25:46 am
http://issues.ez.no/IssueView.php?Id=12862&
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription @: http://twitter.com/andrerom