protected function removeDir($src)
    {

        // open the directory
        $dir = opendir($src);

        // remove files/folders recursively
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                $full = $src . '/' . $file;
                if (is_dir($full)) {
                    $this->removeDir($full);
                } else {
                    if (!unlink($full)) {
                        throw new \Exception(sprintf('Can\'t remove file %s', $full));
                    }
                }
            }
        }

        // close handle and remove directory itself
        closedir($dir);
        if (!rmdir($src)) {
            throw new \Exception(sprintf('Can\'t remove directory %s', $src));
        }
    }
protected function removeDir($src)
    {

        // open the directory
        $dir = opendir($src);

        // remove files/folders recursively
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                $full = $src . '/' . $file;
                if (is_dir($full)) {
                    $this->removeDir($full);
                } else {
                    if (!unlink($full)) {
                        throw new \Exception(sprintf('Can\'t remove file %s', $full));
                    }
                }
            }
        }

        // close handle and remove directory itself
        closedir($dir);
        if (!rmdir($src)) {
            throw new \Exception(sprintf('Can\'t remove directory %s', $src));
        }
    }
protected function removeDir ( $ src ) { // open the directory $ dir = opendir ( $ src ) ; // remove files/folders recursively while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( ( $ file != '.' ) && ( $ file != '..' ) ) { $ full = $ src . '/' . $ file ; if ( is_dir ( $ full ) ) { $ this -> removeDir ( $ full ) ; } else { if ( ! unlink ( $ full ) ) { throw new \ Exception ( sprintf ( 'Can\'t remove file %s' , $ full ) ) ; } } } } // close handle and remove directory itself closedir ( $ dir ) ; if ( ! rmdir ( $ src ) ) { throw new \ Exception ( sprintf ( 'Can\'t remove directory %s' , $ src ) ) ; } }
Removes the passed directory recursively.

@param string $src Name of the directory to remove

@return void
@throws \Exception Is thrown, if the directory can not be removed
Removes the passed directory recursively .