Skip to content

Commit 2bb2cb4

Browse files
committed
update autoload recursive add files
1 parent 7305f2e commit 2bb2cb4

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

autoload.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,32 @@
88
require_once __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoload.php';
99
break;
1010
default:
11-
$path = __DIR__ . DIRECTORY_SEPARATOR . 'src';
11+
requeirFiles( __DIR__ . DIRECTORY_SEPARATOR . 'src');
1212

13-
$iterator = new DirectoryIterator($path);
13+
break;
14+
}
15+
16+
/**
17+
* @param string $path
18+
*/
19+
function requeirFiles(string $path)
20+
{
21+
$iterator = new DirectoryIterator($path);
1422

15-
while ($iterator->valid()) {
16-
$item = $iterator->current();
23+
while ($iterator->valid()) {
24+
$item = $iterator->current();
1725

26+
if (!$item->isDot()) {
1827
if ($item->isFile()) {
1928
require_once $path . DIRECTORY_SEPARATOR . $item->getFilename();
29+
} elseif ($item->isDir()) {
30+
requeirFiles($item->getPathname());
2031
}
21-
22-
unset($item);
23-
$iterator->next();
2432
}
2533

26-
break;
34+
unset($item);
35+
$iterator->next();
36+
}
37+
38+
unset($iterator);
2739
}

0 commit comments

Comments
 (0)