public static function rcopy($src, $dest)
    {

        // If the src is not a directory do a simple file copy
        if (!is_dir($src)) {
            copy($src, $dest);
            return true;
        }

        // If the destination directory does not exist create it
        if (!is_dir($dest)) {
            static::create($dest);
        }

        // Open the source directory to read in files
        $i = new \DirectoryIterator($src);
        /** @var \DirectoryIterator $f */
        foreach ($i as $f) {
            if ($f->isFile()) {
                copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
            } else {
                if (!$f->isDot() && $f->isDir()) {
                    static::rcopy($f->getRealPath(), "{$dest}/{$f}");
                }
            }
        }
        return true;
    }
public static function rcopy($src, $dest)
    {

        // If the src is not a directory do a simple file copy
        if (!is_dir($src)) {
            copy($src, $dest);
            return true;
        }

        // If the destination directory does not exist create it
        if (!is_dir($dest)) {
            static::create($dest);
        }

        // Open the source directory to read in files
        $i = new \DirectoryIterator($src);
        /** @var \DirectoryIterator $f */
        foreach ($i as $f) {
            if ($f->isFile()) {
                copy($f->getRealPath(), "{$dest}/" . $f->getFilename());
            } else {
                if (!$f->isDot() && $f->isDir()) {
                    static::rcopy($f->getRealPath(), "{$dest}/{$f}");
                }
            }
        }
        return true;
    }
public static function rcopy ( $ src , $ dest ) { // If the src is not a directory do a simple file copy if ( ! is_dir ( $ src ) ) { copy ( $ src , $ dest ) ; return true ; } // If the destination directory does not exist create it if ( ! is_dir ( $ dest ) ) { static :: create ( $ dest ) ; } // Open the source directory to read in files $ i = new \ DirectoryIterator ( $ src ) ; /** @var \DirectoryIterator $f */ foreach ( $ i as $ f ) { if ( $ f -> isFile ( ) ) { copy ( $ f -> getRealPath ( ) , "{$dest}/" . $ f -> getFilename ( ) ) ; } else { if ( ! $ f -> isDot ( ) && $ f -> isDir ( ) ) { static :: rcopy ( $ f -> getRealPath ( ) , "{$dest}/{$f}" ) ; } } } return true ; }
Recursive copy of one directory to another

@param string $src
@param string $dest

@return bool
@throws \RuntimeException
Recursive copy of one directory to another