Download the PHP package motekar/laravel-zip without Composer
On this page you can find all versions of the php package motekar/laravel-zip. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download motekar/laravel-zip
More information about motekar/laravel-zip
Files in motekar/laravel-zip
Package laravel-zip
Short Description This is a little neat helper for the ZipArchive methods with handy functions
License Apache-2.0
Homepage http://github.com/motekar/laravel-zip
Informations about the package laravel-zip
Laravel Zip - Create and Manage Zip Archives in Laravel
This package provides a simple and intuitive way to create and manage Zip archives in Laravel applications. It wraps PHP's ZipArchive class with additional convenience methods and fluent syntax.
Quick Example
This code creates a zip file named images.zip
in the storage directory, containing all files from the storage/images/
folder.
Installation
Install the package via Composer:
Usage
Important Notes:
- Always call
->close()
at the end to write changes to disk - Most methods are chainable except:
getFileContent
getStatus
close
extractTo
API Reference
make($pathToFile)
Creates or opens a zip archive. If the file doesn't exist, it creates a new one. Returns the ZipManager instance for method chaining.
add($filesOrFolder)
Adds files or folders to the archive. Accepts:
- An array of file paths
- A single folder path (all files in the folder will be added)
addString($filename, $content)
Adds a file to the archive using string content.
remove($files)
Removes files from the archive. Accepts:
- A single file path
- An array of file paths
folder($folder)
Sets the working folder for subsequent operations.
listFiles($regexFilter = null)
Lists files in the archive. Optionally filters files using a regex pattern.
Note: Ignores the folder set with folder()
Examples:
home()
Resets the folder pointer to the root.
getFileContent($filePath)
Returns the content of a file from the archive or false if not found.
getStatus()
Returns the opening status of the zip archive as an integer.
close()
Writes all changes and closes the archive.
extractTo($path, $files = [], $flags = 0)
Extracts archive contents to the specified path. Supports:
- ZipManager::WHITELIST: Extract only specified files
- ZipManager::BLACKLIST: Extract all except specified files
- ZipManager::EXACT_MATCH: Match file names exactly
Examples:
extractMatchingRegex($path, $regex)
Extracts files matching a regular expression pattern.
Examples:
Important Notes:
- PHP's ZipArchive uses '/' as the directory separator
- Windows users should use '/' in patterns instead of '\'
Credits
- Fauzie Rofi
- Nils Plaschke
- All Contributors
License
This package is open-source software licensed under the Apache Version 2.0 license.
All versions of laravel-zip with dependencies
ext-zip Version *
illuminate/filesystem Version ^10.0||^11.0
illuminate/support Version ^10.0||^11.0
spatie/laravel-package-tools Version ^1.17
spatie/temporary-directory Version ^2.2