public function copyAll($source, $destination, array $skip = ['.git', '.DS_Store'], $override = false)
    {
        if (is_dir($source) && !is_dir($destination)) {
            if (!mkdir($destination, 0755, true)) {
                throw new \RuntimeException("Failed to create directory: " . $destination);
            }
        }

        if (is_dir($source)) {
            // Prevent infinite recursion when the destination is inside the
            // source.
            if (strpos($destination, $source) === 0) {
                $relative = str_replace($source, '', $destination);
                $parts = explode('/', ltrim($relative, '/'), 2);
                $skip[] = $parts[0];
            }

            $sourceDirectory = opendir($source);
            while ($file = readdir($sourceDirectory)) {
                // Skip symlinks, '.' and '..', and files in $skip.
                if ($file === '.'
                    || $file === '..'
                    || $this->inBlacklist($file, $skip)
                    || is_link($source . '/' . $file)) {
                    continue;
                }

                // Recurse into directories.
                if (is_dir($source . '/' . $file)) {
                    $this->copyAll($source . '/' . $file, $destination . '/' . $file, $skip, $override);
                    continue;
                }

                // Perform the copy.
                if (is_file($source . '/' . $file)) {
                    $this->fs->copy($source . '/' . $file, $destination . '/' . $file, $override);
                }
            }
            closedir($sourceDirectory);
        } else {
            $this->fs->copy($source, $destination, $override);
        }
    }
public function copyAll($source, $destination, array $skip = ['.git', '.DS_Store'], $override = false)
    {
        if (is_dir($source) && !is_dir($destination)) {
            if (!mkdir($destination, 0755, true)) {
                throw new \RuntimeException("Failed to create directory: " . $destination);
            }
        }

        if (is_dir($source)) {
            // Prevent infinite recursion when the destination is inside the
            // source.
            if (strpos($destination, $source) === 0) {
                $relative = str_replace($source, '', $destination);
                $parts = explode('/', ltrim($relative, '/'), 2);
                $skip[] = $parts[0];
            }

            $sourceDirectory = opendir($source);
            while ($file = readdir($sourceDirectory)) {
                // Skip symlinks, '.' and '..', and files in $skip.
                if ($file === '.'
                    || $file === '..'
                    || $this->inBlacklist($file, $skip)
                    || is_link($source . '/' . $file)) {
                    continue;
                }

                // Recurse into directories.
                if (is_dir($source . '/' . $file)) {
                    $this->copyAll($source . '/' . $file, $destination . '/' . $file, $skip, $override);
                    continue;
                }

                // Perform the copy.
                if (is_file($source . '/' . $file)) {
                    $this->fs->copy($source . '/' . $file, $destination . '/' . $file, $override);
                }
            }
            closedir($sourceDirectory);
        } else {
            $this->fs->copy($source, $destination, $override);
        }
    }
public function copyAll ( $ source , $ destination , array $ skip = [ '.git' , '.DS_Store' ] , $ override = false ) { if ( is_dir ( $ source ) && ! is_dir ( $ destination ) ) { if ( ! mkdir ( $ destination , 0755 , true ) ) { throw new \ RuntimeException ( "Failed to create directory: " . $ destination ) ; } } if ( is_dir ( $ source ) ) { // Prevent infinite recursion when the destination is inside the // source. if ( strpos ( $ destination , $ source ) === 0 ) { $ relative = str_replace ( $ source , '' , $ destination ) ; $ parts = explode ( '/' , ltrim ( $ relative , '/' ) , 2 ) ; $ skip [ ] = $ parts [ 0 ] ; } $ sourceDirectory = opendir ( $ source ) ; while ( $ file = readdir ( $ sourceDirectory ) ) { // Skip symlinks, '.' and '..', and files in $skip. if ( $ file === '.' || $ file === '..' || $ this -> inBlacklist ( $ file , $ skip ) || is_link ( $ source . '/' . $ file ) ) { continue ; } // Recurse into directories. if ( is_dir ( $ source . '/' . $ file ) ) { $ this -> copyAll ( $ source . '/' . $ file , $ destination . '/' . $ file , $ skip , $ override ) ; continue ; } // Perform the copy. if ( is_file ( $ source . '/' . $ file ) ) { $ this -> fs -> copy ( $ source . '/' . $ file , $ destination . '/' . $ file , $ override ) ; } } closedir ( $ sourceDirectory ) ; } else { $ this -> fs -> copy ( $ source , $ destination , $ override ) ; } }
Copy all files and folders between directories.

@param string $source
@param string $destination
@param array  $skip
@param bool   $override
Copy all files and folders between directories .