|
16 | 16 | define('PFC_BIN_DIR', __DIR__ . '/../bin/'); |
17 | 17 |
|
18 | 18 | /** |
19 | | - * Register PhpFastCache Autoload |
20 | | - */ |
21 | | -set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); |
22 | | -spl_autoload_register(); |
23 | | - |
24 | | -/** |
25 | | - * Register PhpFastCache |
26 | | - * embedded-libraries Autoload |
| 19 | + * Register Autoload |
27 | 20 | */ |
28 | 21 | spl_autoload_register(function ($entity) { |
29 | | - /** |
30 | | - * Attempting to load Psr\Cache |
31 | | - */ |
32 | | - if (strpos($entity, 'Psr\Cache') === 0) { |
| 22 | + $module = explode('\\', $entity, 2); |
| 23 | + if (!in_array($module[ 0 ], ['phpFastCache', 'Psr'])) { |
| 24 | + /** |
| 25 | + * Not a part of phpFastCache file |
| 26 | + * then we return here. |
| 27 | + */ |
| 28 | + return; |
| 29 | + } else if (strpos($entity, 'Psr\Cache') === 0) { |
33 | 30 | $path = PFC_BIN_DIR . 'legacy/Psr/Cache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT; |
34 | 31 |
|
35 | 32 | if (is_readable($path)) { |
|
38 | 35 | trigger_error('Cannot locate the Psr/Cache files', E_USER_ERROR); |
39 | 36 | } |
40 | 37 | return; |
41 | | - } |
42 | | - |
43 | | - /** |
44 | | - * Attempting to load Psr\SimpleCache |
45 | | - */ |
46 | | - if (strpos($entity, 'Psr\SimpleCache') === 0) { |
| 38 | + } else if (strpos($entity, 'Psr\SimpleCache') === 0) { |
47 | 39 | $path = PFC_BIN_DIR . 'legacy/Psr/SimpleCache/src/' . substr(strrchr($entity, '\\'), 1) . '.' . PFC_PHP_EXT; |
48 | 40 |
|
49 | 41 | if (is_readable($path)) { |
|
53 | 45 | } |
54 | 46 | return; |
55 | 47 | } |
| 48 | + |
| 49 | + $entity = str_replace('\\', '/', $entity); |
| 50 | + $path = __DIR__ . '/' . $entity . '.' . PFC_PHP_EXT; |
| 51 | + |
| 52 | + if (is_readable($path)) { |
| 53 | + require_once $path; |
| 54 | + } |
56 | 55 | }); |
57 | 56 |
|
58 | 57 | if ((!defined('PFC_IGNORE_COMPOSER_WARNING') || !PFC_IGNORE_COMPOSER_WARNING) && class_exists('Composer\Autoload\ClassLoader')) { |
|
0 commit comments