__autoload disaster - conflicts with Joomla

Enrollateelve

New Member
I have just changed all my code to use __autoload to find that it conflicts with the joomla autoloader. I integrate my app with joomla in some cases to register users etc.I found spl_autoload_register() with aparently allows many autoloaders.What should I do?update: this is what joomla doesLoads this file from /library/loader.php\[code\]function __autoload($class){ if(JLoader::load($class)) { return true; } return false;}\[/code\]Update 2:OK, right after I load the Joomla library I call \[code\] require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' ); //autoloader so that it does not interfere with mine spl_autoload_register('__autoload');\[/code\]This is what my autoload looks like:\[code\]<?php//IMPORTfunction myAutoload($class_name){ $path = str_replace('_', '/', $class_name); include $path . '.php';}?>spl_autoload_register('myAutoload',false,true);\[/code\]Mine gets called first and the joomla one second, however, the the app still can't find the Joomla classes.Update 3:After running:\[code\]echo "PRE: myAutoload:" . spl_autoload_functions() . "<br />";spl_autoload_register('myAutoload',false,true);echo "POST: myAutoload:" . spl_autoload_functions() . "<br />";\[/code\]and\[code\] echo "PRE: JoomlaAutoLoad:" . spl_autoload_functions() . "<br />"; //autoloader so that it does not interfere with mine spl_autoload_register('__autoload'); echo "POST: JoomlaAutoLoad:" . spl_autoload_functions() . "<br />";\[/code\]My output was:pRE: myAutoload:pOST: myAutoload:ArrayUPDATE 4:I had to change the Joomla imports to this:\[code\] require_once ( JPATH_BASE .DS.'libraries'.DS.'loader.php' ); echo "PRE: JoomlaAutoLoad:" . var_dump(spl_autoload_functions()) . "<br />"; //autoloader so that it does not interfere with mine spl_autoload_register('__autoload'); echo "POST: JoomlaAutoLoad:" . var_dump(spl_autoload_functions()) . "<br />"; require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );\[/code\]Here is the output\[code\]PRE: myAutoload:array 0 => string 'myAutoload' (length=10)POST: myAutoload:array 0 => string 'myAutoload' (length=10)PRE: JoomlaAutoLoad:array 0 => string 'myAutoload' (length=10) 1 => string '__autoload' (length=10)POST: JoomlaAutoLoad:\[/code\]I have worked out that after I include these Joomla files\[code\] require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' ); require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );\[/code\]The spl_autoload_functions() returns nothing, so somehow joomla is stuffing it up.
 
Top