public static function copy($src, $dst)
    {
        if (!is_dir($src)) {
            throw new RuntimeException(sprintf('Invalid directory path supplied "%s"', $src));
        }

        $dir = opendir($src);

        if (!is_dir($dst)) {
            mkdir($dst, 0777);
        }

        while (false !== ($file = readdir($dir))) {
            // We must ensure a file isn't a dot
            if (($file != '.' ) && ($file != '..' )) {
                if (is_dir($src . '/' . $file)) {
                    // Recursive call
                    call_user_func(__METHOD__, $src . '/' . $file, $dst . '/' . $file); 
                } else {
                    copy($src . '/' . $file, $dst . '/' . $file); 
                }
            }
        }

        closedir($dir);
        return true;
    }
public static function copy($src, $dst)
    {
        if (!is_dir($src)) {
            throw new RuntimeException(sprintf('Invalid directory path supplied "%s"', $src));
        }

        $dir = opendir($src);

        if (!is_dir($dst)) {
            mkdir($dst, 0777);
        }

        while (false !== ($file = readdir($dir))) {
            // We must ensure a file isn't a dot
            if (($file != '.' ) && ($file != '..' )) {
                if (is_dir($src . '/' . $file)) {
                    // Recursive call
                    call_user_func(__METHOD__, $src . '/' . $file, $dst . '/' . $file); 
                } else {
                    copy($src . '/' . $file, $dst . '/' . $file); 
                }
            }
        }

        closedir($dir);
        return true;
    }
public static function copy ( $ src , $ dst ) { if ( ! is_dir ( $ src ) ) { throw new RuntimeException ( sprintf ( 'Invalid directory path supplied "%s"' , $ src ) ) ; } $ dir = opendir ( $ src ) ; if ( ! is_dir ( $ dst ) ) { mkdir ( $ dst , 0777 ) ; } while ( false !== ( $ file = readdir ( $ dir ) ) ) { // We must ensure a file isn't a dot if ( ( $ file != '.' ) && ( $ file != '..' ) ) { if ( is_dir ( $ src . '/' . $ file ) ) { // Recursive call call_user_func ( __METHOD__ , $ src . '/' . $ file , $ dst . '/' . $ file ) ; } else { copy ( $ src . '/' . $ file , $ dst . '/' . $ file ) ; } } } closedir ( $ dir ) ; return true ; }
Copies a directory to another directory

@param string $file The path to the file
@param string $dir The dir file will be copied in
@throws \RuntimeException if $src isn't a path to directory
@return boolean Depending on success
Copies a directory to another directory