On 07.02.2011, at 10:37, Sven Paulus wrote:

> It would be great if there was a (optional?) way to use the universal class 
> loader without calling file_exists() at all:
> 
> If you are running in a high volume environment, you are likely using APC 
> with apc.stat = 0 (see 
> http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat) so that once 
> all the classes are cached in memory, the file system layer doesn't need to 
> get involved any more (no stat(2) calls needed at all).
> 
> However if the universal class loader uses file_exists() every time before 
> doing a require() the main purpose of this optimization is gone, because 
> there still will be a stat(2) system call every time a class is accessed for 
> the first time within a request.
> 
> Having an option to disable file_exists() and use an unambiguous mapping from 
> class name to file name would take a lot of pressure from the IO layer (which 
> is e.g. especially important if you're running the web farm from a NFSv3 
> based filer which doesn't allow client side caching).

one of the problems is of course that the current implementation supports 
iterating over multiple possible paths for a namespace. i am not sure if there 
is any case where you cannot set things up to always match the first option.

if this is possible the code could potentially look more like the following:

$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, 
$namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, 
$className).'.php';
$return = @include $file;
if ($return) {
    return;
}
if (stream_resolve_include_path($file)) {
    // fail loudly
    require $file;
    return;
}

regards,
Lukas Kahwe Smith
[email protected]



-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to