public static function copyRecursive($source, $destination)
    {
        if (!is_dir($destination)) {
            mkdir($destination);
        }

        $dir = opendir($source);

        if (!$dir) {
            throw new RuntimeException("Cannot copy '$source' to '$destination'");
        }

        while (false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
                    static::copyRecursive(
                        $source . DIRECTORY_SEPARATOR . $file,
                        $destination . DIRECTORY_SEPARATOR . $file
                    );
                } else {
                    copy($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file);
                }
            }
        }
        closedir($dir);
    }
public static function copyRecursive($source, $destination)
    {
        if (!is_dir($destination)) {
            mkdir($destination);
        }

        $dir = opendir($source);

        if (!$dir) {
            throw new RuntimeException("Cannot copy '$source' to '$destination'");
        }

        while (false !== ($file = readdir($dir))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
                    static::copyRecursive(
                        $source . DIRECTORY_SEPARATOR . $file,
                        $destination . DIRECTORY_SEPARATOR . $file
                    );
                } else {
                    copy($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file);
                }
            }
        }
        closedir($dir);
    }
public static function copyRecursive ( $ source , $ destination ) { if ( ! is_dir ( $ destination ) ) { mkdir ( $ destination ) ; } $ dir = opendir ( $ source ) ; if ( ! $ dir ) { throw new RuntimeException ( "Cannot copy '$source' to '$destination'" ) ; } while ( false !== ( $ file = readdir ( $ dir ) ) ) { if ( $ file != '.' && $ file != '..' ) { if ( is_dir ( $ source . DIRECTORY_SEPARATOR . $ file ) ) { static :: copyRecursive ( $ source . DIRECTORY_SEPARATOR . $ file , $ destination . DIRECTORY_SEPARATOR . $ file ) ; } else { copy ( $ source . DIRECTORY_SEPARATOR . $ file , $ destination . DIRECTORY_SEPARATOR . $ file ) ; } } } closedir ( $ dir ) ; }
Copy files recursively

@param string $source
@param string $destination
Copy files recursively