class Zipper implements WriterInterface (View source)

Class that generate a ZIP archive containing the package files.

Properties

protected string $zipFilename

The absolute path to the ZIP archive to be created.

protected string $rootDirectory

The root directory inside the ZIP archive (empty string to not create a main directory inside the ZIP archive).

protected OutputInterface $output
protected Filesystem $fs
protected array $directoriesToAdd
protected array $filesToAdd

Methods

__construct(string $zipFilename, string $rootDirectory, OutputInterface $output, Filesystem $fs)

Initialize the instance.

$this
add(PackerFile $file)

Add a file/directory.

completed()

Called after all the files have been processed succesfully.

ZipArchive
createZipArchive()

Create the ZIP archive.

addRootDirectory(ZipArchive $zipArchive)

Create the root directory inside the archive (if specified), and returns the prefix for further files/directoryes added to the archive.

addDirectory(ZipArchive $zipArchive, string $relativePath)

Add a directory to a ZIP archive.

addFile(ZipArchive $zipArchive, string $sourceFile, string $relativePath)

Add a directory to a ZIP archive.

Details

__construct(string $zipFilename, string $rootDirectory, OutputInterface $output, Filesystem $fs)

Initialize the instance.

Parameters

string $zipFilename

the absolute path to the ZIP archive to be created

string $rootDirectory

the root directory inside the ZIP archive (empty string to not create a main directory inside the ZIP archive)

OutputInterface $output
Filesystem $fs

$this add(PackerFile $file)

Add a file/directory.

Parameters

PackerFile $file

Return Value

$this

See also

WriterInterface::add

completed()

Called after all the files have been processed succesfully.

protected ZipArchive createZipArchive()

Create the ZIP archive.

Return Value

ZipArchive

Exceptions

RuntimeException

protected addRootDirectory(ZipArchive $zipArchive)

Create the root directory inside the archive (if specified), and returns the prefix for further files/directoryes added to the archive.

Parameters

ZipArchive $zipArchive

Exceptions

RuntimeException

protected addDirectory(ZipArchive $zipArchive, string $relativePath)

Add a directory to a ZIP archive.

Parameters

ZipArchive $zipArchive
string $relativePath

Exceptions

RuntimeException

protected addFile(ZipArchive $zipArchive, string $sourceFile, string $relativePath)

Add a directory to a ZIP archive.

Parameters

ZipArchive $zipArchive
string $sourceFile
string $relativePath

Exceptions

RuntimeException