5fb876a7e330467ce6f85ebbd1a056e8fa53b741
[anoweco.git] / src / anoweco / autoload.php
1 <?php
2 /**
3  * Autoloader setup for anoweco
4  *
5  * @author Christian Weiske <cweiske@cweiske.de>
6  */
7 if (file_exists(__DIR__ . '/../../lib/PEAR.php')) {
8     //phing-installed dependencies available ("phing collectdeps")
9     set_include_path(
10         __DIR__ . '/../'
11         . PATH_SEPARATOR . __DIR__ . '/../../lib/'
12         . PATH_SEPARATOR . '.'
13     );
14 } else if (file_exists(__DIR__ . '/../../lib/autoload.php')) {
15     //composer-installed dependencies available
16     set_include_path(
17         __DIR__ . '/../'
18         . PATH_SEPARATOR . '.'
19     );
20     require_once __DIR__ . '/../../lib/autoload.php';
21 } else {
22     //use default include path for dependencies
23     set_include_path(
24         __DIR__ . '/../'
25         . PATH_SEPARATOR . get_include_path()
26     );
27 }
28
29 spl_autoload_register(
30     function ($class) {
31         $file = str_replace(array('\\', '_'), '/', $class) . '.php';
32         if (stream_resolve_include_path($file)) {
33             require $file;
34         }
35     }
36 );
37 ?>