private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
private function copyRecursive ( $ source , $ target ) { if ( ! is_dir ( $ source ) ) { $ this -> filesystem -> ensureDirectoryExists ( dirname ( $ target ) ) ; copy ( $ source , $ target ) ; return ; } $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ source , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; $ this -> filesystem -> ensureDirectoryExists ( $ target ) ; foreach ( $ iterator as $ file ) { $ targetPath = $ target . DIRECTORY_SEPARATOR . $ iterator -> getSubPathName ( ) ; if ( $ file -> isDir ( ) ) { $ this -> filesystem -> ensureDirectoryExists ( $ targetPath ) ; } else { copy ( $ file -> getPathname ( ) , $ targetPath ) ; } } }
Recursive copy source file or directory to target path.

@param string $source The source file or folder.
@param string $target The target file or folder.

@return void
Recursive copy source file or directory to target path .