sane psr-0 autoloader

raw

README.rst

A sensible PSR-0 compatible autoloader that plays nice with other autoloaders.

It only loads a file if it actually exists.

This fixes https://github.com/php-fig/fig-standards/pull/159

raw

autoloader.php

1
2
3
4
5
6
7
8
9
10
11
<?php
spl_autoload_register(
    function ($class) {
        $file = str_replace(array('\\', '_'), '/', $class) . '.php';
        if (stream_resolve_include_path($file) !== false) {
            require $file;
        }
    }
);
?>
 
raw

include-path.php

1
2
3
4
<?php
set_include_path(__DIR__ . '/src/' . PATH_SEPARATOR . get_include_path());
?>
 
Christian Weiske Christian Weiske
owner

History