public function withPath($path = __DIR__)
    {
        $before = get_declared_classes();

        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
        foreach ($iterator as $item) {
            if (!$item->isDir() && substr($item->getPathname(), -4) == '.php') {
                require_once $item->getPathname();
            }
        }

        $after    = get_declared_classes();
        $commands = array_diff($after, $before);

        $this->withCommands($commands);

        return $this;
    }
public function withPath($path = __DIR__)
    {
        $before = get_declared_classes();

        $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
        foreach ($iterator as $item) {
            if (!$item->isDir() && substr($item->getPathname(), -4) == '.php') {
                require_once $item->getPathname();
            }
        }

        $after    = get_declared_classes();
        $commands = array_diff($after, $before);

        $this->withCommands($commands);

        return $this;
    }
public function withPath ( $ path = __DIR__ ) { $ before = get_declared_classes ( ) ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path ) ) ; foreach ( $ iterator as $ item ) { if ( ! $ item -> isDir ( ) && substr ( $ item -> getPathname ( ) , - 4 ) == '.php' ) { require_once $ item -> getPathname ( ) ; } } $ after = get_declared_classes ( ) ; $ commands = array_diff ( $ after , $ before ) ; $ this -> withCommands ( $ commands ) ; return $ this ; }
Add commands from path recursively

@param string $path

@return $this
Add commands from path recursively