aboutsummaryrefslogtreecommitdiff
path: root/src/phorkie/autoload.php
blob: 6441a1a71790fc8b7ab13494f701c7e5cb3589fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * Autoloader setup for phorkie
 *
 * @author Christian Weiske <cweiske@cweiske.de>
 */
if (file_exists(__DIR__ . '/../../lib/PEAR.php')) {
    //phing-installed dependencies available ("phing collectdeps")
    set_include_path(
        __DIR__ . '/../'
        . PATH_SEPARATOR . __DIR__ . '/../../lib/'
        . PATH_SEPARATOR . '.'
    );
} else if (file_exists(__DIR__ . '/../../lib/autoload.php')) {
    //composer-installed dependencies available
    set_include_path(
        __DIR__ . '/../'
        . PATH_SEPARATOR . '.'
    );
    require_once __DIR__ . '/../../lib/autoload.php';
} else {
    //use default include path for dependencies
    set_include_path(
        __DIR__ . '/../'
        . PATH_SEPARATOR . get_include_path()
    );
}

spl_autoload_register(
    function ($class) {
        $file = str_replace(array('\\', '_'), '/', $class) . '.php';
        if (stream_resolve_include_path($file)) {
            require $file;
        }
    }
);
?>