|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-02-25 14:00 UTC] davi dot fol at gmail dot com
Description:
------------
I am aware of spl_autoload_* issues that the development team do not
consider bugs, namely the requirement for class files to have
lowercase names in order for spl_autoload to function. (I would like
to think that moving forwards, we could supply a constant to
spl_register_autoload as a best compromise BC step to change this
behaviour to support PascalCase class names).
Anyhow, I've disabled all extensions, I believe I've exhausted all
configuration possibilities affecting spl_autoloads behaviour, and
it still does not work. Defining my own handler, does. It seems that
no matter how I define the include path, spl_autoload throws
LogicExceptions as it cannot find classes. I am hoping that its not
the case that as Mac OSX paths contain upper case folder names,
that the auto lowercasing behaviour of spl_autoload is affecting
absolute paths.
As a concrete case, this IS an include path that I use- it works with
include_once et al, supplying or omitting the trailing slash:
"/Users/davidfoley/Documents/Aptana Studio
Workspace/www.thorium.site/Private/Library/"
The above path is a perfectly valid file path- its somewhat different
in the sense that 'www.thorium.site' is plonked in the middle-
thats simply the name of a virtual hosts symlinked folder. I am only
guessing that this could be a possible reason why spl_autoload is
not working.
Reproduce code:
---------------
Assume a class file:
location:
www/Private/library/target.php
contents:
namespace library
{
class target
{
}
}
Assume a bootloader script
location:
www/Public/boot.php
contents:
define('BREAK', '<br/>');
set_include_path('absolute/path/to/www/Private/library);
spl_autoload_extensions('.php');
spl_autoload_register();
$classFile= new SplFileObject('library/target.php', true);
echo 'The class file exists: ' . ($classFile->isFile() ? 'true' : 'false') . BREAK;
use library\target;
$instance= new target;
echo 'The class was loaded: ' . (isset($instance) ? 'true' : 'false') . BREAK;
Expected result:
----------------
The following output:
The class file exists: true
The class was loaded: true
Actual result:
--------------
LogicException 'could not load class library\target'
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 22:00:01 2025 UTC |
> could not load class library\target The autoloader is looking for library/target.php, but obviously this file doesn't exist. Changing the include_path appropriately is supposed to solve the issue: set_include_path('absolute/path/to/www/Private');