Download the PHP package verseles/sevenzip without Composer

On this page you can find all versions of the php package verseles/sevenzip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sevenzip

SevenZip 🔧

A PHP package to compress and decompress files using 7zip CLI.

GitHub Actions Workflow Status

Installation

Install the package via Composer:

️Star the project to help us reach move devs!️

Usage

Compression

To compress a file or directory:

Compression Options

[!WARNING] The format support depends on your system, architecture, etc. You can always use format() method to set your custom format.

Any set format() which starts with tar. will automatically enable tarBefore(). To disable add ->forceTarBefore(false)

Extraction

To extract an archive:

If the extracted file is a single tar archive, it will be extracted and the tar file deleted. To avoid this behavior, add ->autoUntar(false)

Encryption

You can encrypt the compressed archive using a password:

By default, the file names are also encrypted (not possible in zip format). If you want to disable file name encryption, you can use the notEncryptNames() method:

For ZIP archives, you can specify the encryption method using the setZipEncryptionMethod() method. Available options are 'ZipCrypto' (not secure), ' AES128', 'AES192', or 'AES256'. The default is 'AES256'.

Decryption

To decrypt an encrypted archive during extraction:

Including and Excluding Files

SevenZip allows you to include or exclude specific files when compressing or extracting archives.

Including Files

To include specific files in the archive, use the include method:

Excluding Files

To exclude specific files from the archive, use the exclude method:

Note that you can use both include and exclude methods together to fine-tune the files included in the archive.

You can pass a single file pattern, an array of file patterns or the path to a txt file with a list of patterns inside to the exclude and include methods.

Checking format support

You can check if a specific format or multiple formats are supported by the current 7-Zip installation using the checkSupport method:

TODO / WIP

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Make your changes and commit them with descriptive commit messages
  4. Push your changes to your forked repository
  5. Submit a pull request to the main repository

Please ensure that your code follows the project's coding style and conventions. Also, include appropriate tests for your changes.

Testing

To run the tests, execute the following command:

Documentation / API

Here is the Documentation / API section of the README, updated with missing public methods and ordered alphabetically:

Documentation / API

addFlag(string $flag, $value = null): static

Adds a compression flag.

Parameters

Returns: The current instance of the SevenZip class.

Example

checkSupport(string|array $extensions): bool

Checks if the given extension(s) are supported by the current 7-Zip installation.

Parameters

Returns: Returns true if all the given extensions are supported, false otherwise.

Example

compress(): string

Compresses a file or directory.

Returns: the command output on success.

Throws

Example

copy(): static

Configures no compression (copy only) settings based on the specified format.

Returns: The current instance for method chaining.

decrypt(string $password): self

Decrypts the data using the provided password.

Parameters

Returns: The current instance of this class.

encrypt(string $password): self

Encrypts the data using the provided password.

Parameters

Returns: The current instance of this class.

extract(): string

Extracts an archive.

Returns: the command output on success.

Throws

Example

faster(): static

Sets the compression level to faster.

Returns: The current instance of the SevenZip class.

deleteSourceAfterExtract(bool $delete = true): self

Sets whether to delete the source archive after successful extraction.

Parameters

Returns: The current instance of the SevenZip class.

Example

fileInfo(): string

Retrieves information about the specified archive file.

Returns: The file information output from the 7-Zip command.

Throws

Example

fileList(): string

Lists the contents of the specified archive file.

Returns: The file list output from the 7-Zip command.

Throws

Example

flagrize(array $flagsAndValues): array

Formats flags and values into an array of strings suitable for passing to 7-Zip commands.

Parameters

Returns: An array of formatted flag strings.

Example

format(string $format): static

Sets the archive format.

Parameters

Returns: The current instance of the SevenZip class.

Example

getCustomFlags(): array

Gets the custom compression flags.

Returns: The custom compression flags that have been added.

getEncryptNames(): ?bool

Gets whether or not file names are encrypted.

Returns: Whether or not file names are encrypted, or null if not set.

getFormat(): string

Gets the archive format.

Returns: The compression format to be used.

getInfo()

Returns information about 7-Zip, formats, codecs, and hashers.

Returns: The output from the 7-Zip command.

getLastProgress(): int

Gets the last reported progress.

Returns: The last reported progress percentage.

getPassword(): ?string

Gets the password used for encryption or decryption.

Returns: The password used for encryption or decryption, or null if not set.

getSevenZipPath(): ?string

Gets the path to the 7-Zip executable file.

Returns: Path to the 7-Zip executable file.

getSourcePath(): string

Gets the source path for compression/extraction.

Returns: The path to the source file or directory for compression or extraction.

getSupportedFormatExtensions(?array $formats = null): array

Gets all supported format extensions from the given array.

Parameters

Example

getTargetPath(): string

Gets the target path for compression/extraction.

Returns: The path to the target file or directory for compression or extraction.

getZipEncryptionMethod(): string

Gets the encryption method used for ZIP archives.

Returns: The encryption method used for ZIP archives.

exclude(string|array $patterns): self

Excludes files from the archive based on the provided patterns.

Parameters

Returns: The current instance of the SevenZip class.

Example

include(string|array $patterns): self

Includes only the specified files in the archive based on the provided patterns.

Parameters

Returns: The current instance of the SevenZip class.

Example

info(): void

Prints the information about 7-Zip, formats, codecs, and hashers.

md(string $size = '32m'): self

Sets the dictionary size for the compression algorithm.

Parameters

Returns: The current instance of the SevenZip class.

mfb(int $bytes = 64): self

Sets the size of the Fast Bytes for the compression algorithm.

Parameters

Returns: The current instance of the SevenZip class.

mm(string $method): self

Sets the compression method for ZIP format.

Parameters

Returns: The current instance of the SevenZip class.

mmem(int|string $size = 24): static

Sets the memory limit for compression.

Parameters

Returns: The current instance of the SevenZip class.

Example

mmt(int|bool|string $threads = 'on'): self

Sets the number of CPU threads to use for compression.

Parameters

Returns: The current instance of the SevenZip class.

Example

m0($method): self

Sets the compression method.

Parameters

Returns: The current instance of the SevenZip class.

mpass(int $number = 7): self

Sets the number of passes for compression.

Parameters

Returns: The current instance of the SevenZip class.

Example

ms(bool|string|int $on = true): self

Enables or disables solid compression mode.

Parameters

Returns: The current instance of the SevenZip class.

mx(int $level): static

Sets the compression level using the -mx flag.

Parameters

Returns: The current instance of the SevenZip class.

Example

myx(int $level = 5): self

Sets the file analysis level.

Parameters

Returns: The current instance of the SevenZip class.

notEncryptNames(): self

Disables encryption of file names.

Returns: The current instance of the SevenZip class.

progress(callable $callback): self

Sets the progress callback using a fluent interface.

Parameters

Returns: The current instance of the SevenZip class.

Example

removeFlag(string $flag): self

Removes a compression flag.

Parameters

Returns: The current instance of the SevenZip class.

reset(): SevenZip

Resets the property values to their original state.

Returns: The current instance of the SevenZip class.

setCustomFlags(array $customFlags): SevenZip

Sets the custom compression flags.

Parameters

Returns: The current instance of the SevenZip class.

Example

setEncryptNames(bool $encryptNames): self

Sets whether or not to encrypt file names.

Parameters

Returns: The current instance of the SevenZip class.

setFormat(string $format): self

Sets the archive format.

Parameters

Returns: The current instance of the SevenZip class.

Example

setPassword(?string $password): self

Sets the password for encryption or decryption.

Parameters

Returns: The current instance of the SevenZip class.

setProgressCallback(callable $callback): self

Sets the progress callback.

Parameters

Returns: The current instance of the SevenZip class.

setSevenZipPath(string $sevenZipPath): SevenZip

Sets the path to the 7-Zip executable file.

Parameters

Returns: The current instance of the SevenZip class.

setSourcePath(string $path): static

Sets the source path for compression/extraction.

Parameters

Returns: The current instance of the SevenZip class.

Example

setTargetPath(string $path): static

Sets the target path for compression/extraction.

Parameters

Returns: The current instance of the SevenZip class.

Example

setZipEncryptionMethod(string $method): self

Sets the encryption method for ZIP archives.

Parameters

Returns: The current instance of the SevenZip class.

slower(): static

Sets the compression level to slower.

Returns: The current instance of the SevenZip class.

source(string $path): self

Sets the source path for the compression or extraction operation.

Parameters

Returns: The current instance of the SevenZip class.

target(?string $path): self

Sets the target path for compression/extraction using a fluent interface.

Parameters

Returns: The current instance of the SevenZip class.

tarBefore(bool $keepFileInfo = true): self

Enables creating a tar archive before compressing, preserving file permissions and attributes by default.

Parameters

Returns: The current instance of the SevenZip class.

Example

forceTarBefore(bool $force): self

Sets whether to force creating a tar archive before compressing, regardless of the format.

Parameters

Returns: The current instance of the SevenZip class.

Example

setTarKeepFileInfo(bool $keepFileInfo): self

Sets whether to preserve file permissions and attributes when creating a tar archive before compressing.

Parameters

Returns: The current instance of the SevenZip class.

Example

shouldForceTarBefore(): bool

Gets whether forcing tar before compression is enabled.

Returns: Whether forcing tar before compression is enabled.

isTarKeepFileInfo(): bool

Gets whether preserving file permissions and attributes when creating a tar archive is enabled.

Returns: Whether preserving file permissions and attributes is enabled.

wasAlreadyTarred(): bool

Checks if the source has already been tarred.

Returns: Whether the source has already been tarred.

ultra(): self

Configures maximum compression settings based on the specified format.

Returns: The current instance for method chaining.

License

This package is open-sourced software licensed under the MIT license.

About 7zip binaries: Most of the source code is under the GNU LGPL license. The unRAR code is under a mixed license with GNU LGPL + unRAR restrictions. Check the license for details.


All versions of sevenzip with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/process Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package verseles/sevenzip contains the following files

Loading the files please wait ....