public function zip($directory, $fileName)
    {
        $path = sprintf('%s/%s/%s.zip', $this->localDirectory, $this->name, $fileName);
        $this->filesystem->mkdir(dirname($path));

        // FIXME find better place for this message
        $this->output->writeln(PHP_EOL . 'Creating zip file (it may take a few minutes) ...');

        $zip = $this->openZip($path);

        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
        foreach ($files as $filePath => $file) {
            $relative = Path::makeRelative($filePath, $directory);
            if (is_dir($filePath)) {
                $zip->addEmptyDir($relative);

                continue;
            }

            $zip->addFile($filePath, $relative);
        }

        $zip->close();

        return $path;
    }
public function zip($directory, $fileName)
    {
        $path = sprintf('%s/%s/%s.zip', $this->localDirectory, $this->name, $fileName);
        $this->filesystem->mkdir(dirname($path));

        // FIXME find better place for this message
        $this->output->writeln(PHP_EOL . 'Creating zip file (it may take a few minutes) ...');

        $zip = $this->openZip($path);

        $files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
        foreach ($files as $filePath => $file) {
            $relative = Path::makeRelative($filePath, $directory);
            if (is_dir($filePath)) {
                $zip->addEmptyDir($relative);

                continue;
            }

            $zip->addFile($filePath, $relative);
        }

        $zip->close();

        return $path;
    }
public function zip ( $ directory , $ fileName ) { $ path = sprintf ( '%s/%s/%s.zip' , $ this -> localDirectory , $ this -> name , $ fileName ) ; $ this -> filesystem -> mkdir ( dirname ( $ path ) ) ; // FIXME find better place for this message $ this -> output -> writeln ( PHP_EOL . 'Creating zip file (it may take a few minutes) ...' ) ; $ zip = $ this -> openZip ( $ path ) ; $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directory ) ) ; foreach ( $ files as $ filePath => $ file ) { $ relative = Path :: makeRelative ( $ filePath , $ directory ) ; if ( is_dir ( $ filePath ) ) { $ zip -> addEmptyDir ( $ relative ) ; continue ; } $ zip -> addFile ( $ filePath , $ relative ) ; } $ zip -> close ( ) ; return $ path ; }
Creates a new zip from the given directory.

@param string $directory
@param string $fileName

@return string

@throws IOException
Creates a new zip from the given directory .