public function deleteFolderRecursively($folderPath)
    {
        $this->throwIfOperationNotInBaseFolder($folderPath);

        $itemIterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($folderPath, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($itemIterator as $item) {
            if ($item->isDir()) {
                rmdir($item->getPathname());
            } else {
                unlink($item->getPathname());
            }
        }

        rmdir($folderPath);
    }
public function deleteFolderRecursively($folderPath)
    {
        $this->throwIfOperationNotInBaseFolder($folderPath);

        $itemIterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($folderPath, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        foreach ($itemIterator as $item) {
            if ($item->isDir()) {
                rmdir($item->getPathname());
            } else {
                unlink($item->getPathname());
            }
        }

        rmdir($folderPath);
    }
public function deleteFolderRecursively ( $ folderPath ) { $ this -> throwIfOperationNotInBaseFolder ( $ folderPath ) ; $ itemIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ folderPath , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ itemIterator as $ item ) { if ( $ item -> isDir ( ) ) { rmdir ( $ item -> getPathname ( ) ) ; } else { unlink ( $ item -> getPathname ( ) ) ; } } rmdir ( $ folderPath ) ; }
Delete the folder at the given path as well as all its contents

@param string $folderPath Path of the folder to delete
@return void
@throws \Box\Spout\Common\Exception\IOException If the folder path is not inside of the base folder
Delete the folder at the given path as well as all its contents