public function loadRoutesFromPath($fromPath, $namespace = '', $hooks=[])
    {
        $dir = @dir($fromPath) or abort("dir $fromPath not exist");

        $getEach = function () use ($dir) {
            $name = $dir->read();
            if (!$name) {
                return $name;
            }
            return $name;
        };

        while (!!($entry = $getEach())) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $path = $fromPath . '/' . str_replace('\\', '/', $entry);
            if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) {
                $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4);
                $this->loadRoutesFromClass($class_name, $hooks);
            } else {
                //\Log::debug($path.' ignored');
            }
        }
    }
public function loadRoutesFromPath($fromPath, $namespace = '', $hooks=[])
    {
        $dir = @dir($fromPath) or abort("dir $fromPath not exist");

        $getEach = function () use ($dir) {
            $name = $dir->read();
            if (!$name) {
                return $name;
            }
            return $name;
        };

        while (!!($entry = $getEach())) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $path = $fromPath . '/' . str_replace('\\', '/', $entry);
            if (is_file($path) && substr_compare($entry, '.php', strlen($entry) - 4, 4, true) == 0) {
                $class_name = $namespace . '\\' . substr($entry, 0, strlen($entry) - 4);
                $this->loadRoutesFromClass($class_name, $hooks);
            } else {
                //\Log::debug($path.' ignored');
            }
        }
    }
public function loadRoutesFromPath ( $ fromPath , $ namespace = '' , $ hooks = [ ] ) { $ dir = @ dir ( $ fromPath ) or abort ( "dir $fromPath not exist" ) ; $ getEach = function ( ) use ( $ dir ) { $ name = $ dir -> read ( ) ; if ( ! $ name ) { return $ name ; } return $ name ; } ; while ( ! ! ( $ entry = $ getEach ( ) ) ) { if ( $ entry == '.' || $ entry == '..' ) { continue ; } $ path = $ fromPath . '/' . str_replace ( '\\' , '/' , $ entry ) ; if ( is_file ( $ path ) && substr_compare ( $ entry , '.php' , strlen ( $ entry ) - 4 , 4 , true ) == 0 ) { $ class_name = $ namespace . '\\' . substr ( $ entry , 0 , strlen ( $ entry ) - 4 ) ; $ this -> loadRoutesFromClass ( $ class_name , $ hooks ) ; } else { //\Log::debug($path.' ignored'); } } }
load routes from path

被加载的文件必须以: 类名.php的形式命名
@param string $fromPath
@param string $namespace
@param string[] $hooks
@return void
load routes from path