Page 1 of 1

n00b having problems with autoloader

PostPosted: January 11th, 2013, 3:57 pm
by stu
Hi there, I'm having problems porting my existing php app which makes use of spl_autoload_register etc.

The phalanger config I'm using is pretty much straight out of the box, and the php app works happily under fast-cgi on iis.

Having googled for a number of hours I can't see anything obvious that would make my autoloader not work, and I can see from phalanger 3 svn repo that there is code in place to support autoloading.

The autoloader code is a pretty straightforward 'swap underscore for separator and rely on the default implementation' ..
Code: Select all
set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
spl_autoload_extensions('.php');
spl_autoload_register(function ($class){return spl_autoload(strtolower(str_replace('_', '/', $class)));});

... so I'm operating under the assumption that there is some config that I'm missing.

Can anyone help me get this going?

thanks

Re: n00b having problems with autoloader

PostPosted: January 11th, 2013, 11:14 pm
by Jakub Misek
Hi,
I've tried the autoload and it works as expected for me.

Try to add some debug prints into your autoload function, whether it is called ... and also check whether 'spl_autoload_register' returns TRUE.

Thanks,