{"id":14975404,"url":"https://github.com/zanysoft/laravel-zip","last_synced_at":"2025-05-14T15:04:40.944Z","repository":{"id":37549838,"uuid":"92492456","full_name":"zanysoft/laravel-zip","owner":"zanysoft","description":"Package for file compression and backup","archived":false,"fork":false,"pushed_at":"2025-03-13T15:38:24.000Z","size":38,"stargazers_count":308,"open_issues_count":4,"forks_count":103,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T13:13:37.574Z","etag":null,"topics":["archive","files","zip","zipfile","zipper"],"latest_commit_sha":null,"homepage":"https://zanysoft.github.io/laravel-zip/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zanysoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-26T09:01:24.000Z","updated_at":"2025-03-24T23:09:17.000Z","dependencies_parsed_at":"2025-03-16T05:01:14.400Z","dependency_job_id":"b831e9fb-af97-4ded-8256-99acfb6b400d","html_url":"https://github.com/zanysoft/laravel-zip","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":0.7241379310344828,"last_synced_commit":"cef15510b82819b1ffafeede76a15bd87bc9634e"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-zip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-zip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-zip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanysoft%2Flaravel-zip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zanysoft","download_url":"https://codeload.github.com/zanysoft/laravel-zip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254168711,"owners_count":22026206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","files","zip","zipfile","zipper"],"created_at":"2024-09-24T13:51:58.958Z","updated_at":"2025-05-14T15:04:40.871Z","avatar_url":"https://github.com/zanysoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zanysoft/laravel-zip\n\n[![Downloads](https://img.shields.io/packagist/dt/zanysoft/laravel-zip.svg?style=flat-square)](https://packagist.org/packages/zanysoft/laravel-zip)\n[![GitHub license](https://img.shields.io/badge/License-MIT-informational.svg)](https://github.com/zanysoft/laravel-zip/blob/master/LICENSE)\n[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-informational.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)\n[![GitHub tag](https://img.shields.io/github/tag/ZanySoft/laravel-zip.svg?style=flat\u0026logo=laravel\u0026color=informational)](https://github.com/zanysoft/laravel-zip/tags)\n\n\n\n\n\u003e laravel-zip is the world's leading zip utility for file compression and backup.\n\nThis library was written to simplify and automate Zip files management using [PHP ZipArchive](http://php.net/manual/en/class.ziparchive.php).\n\n### Installation\nRequire this package in your composer.json and update composer. This will download the package.\n\n    composer require zanysoft/laravel-zip\n\nAfter updating composer, add the ServiceProvider to the providers array in config/app.php\n\n    ZanySoft\\Zip\\ZipServiceProvider::class,\n\nYou can optionally use the facade for shorter code. Add this to your facades:\n\n    'Zip' =\u003e ZanySoft\\Zip\\Facades\\Zip::class,\n\n\n## Zip usage\n\nuse `ZanySoft\\Zip\\Zip` class only use `Zip` is made to handle a zip file.\n\n- include the Zip class at top:\n```php\nuse Zip;\n\n```\n\n### Basic operations\n\n- Open zip file:\n\n    ```php    \n    $zip = Zip::open('file.zip');\n\n    ```\n\n- Create zip file:\n\n    ```php    \n    $zip = Zip::create('file.zip');\n\n    ```\n\n- Check zip file:\n\n    ```php    \n    $is_valid = Zip::check('file.zip');\n\n    ```\n\n- Extract zip file:\n\n    ```php    \n    // extract whole archive\n    $zip-\u003eextract('/path/to/uncompressed/files');\n\n    // extract a file\n    $zip-\u003eextract('/path/to/uncompressed/files', 'file');\n\n    // extract multiple files\n    $zip-\u003eextract('/path/to/uncompressed/files', array('file1','file2'));\n\n    ```\n\t\n- Check if zip has a file:\n\n    ```php    \n    // Check if archive has a file\n    $zip-\u003ehas('/path/to/file/in/archive');\n\n    // Check if archive has a file case insensitively\n    $zip-\u003ehas('/path/to/file/in/archive', ZipArchive::FL_NOCASE);\n\n    // Check if archive has a file ignoring directory component\n    $zip-\u003ehas('file', ZipArchive::FL_NODIR);\n\n    // Check if archive has a file case insensitively ignoring directory component\n    $zip-\u003ehas('file', ZipArchive::FL_NOCASE|ZipArchive::FL_NODIR);\n\n    ```\n\n- Add a file/directory to zip:\n\n    ```php    \n    $zip-\u003eadd('/path/to/my/file');\n\n    // declaring path\n    $zip-\u003esetPath('/path/to/my')-\u003eadd('file');\n\n    // add directory\n    $zip-\u003eadd('/path/to/my/directory');\n\n    // add directory (only its content)\n    $zip-\u003eadd('/path/to/my/directory', true);\n\n    ```\n\n- Add content to zip:\n\n    ```php    \n    $zip-\u003eaddFromString('file name with extension', 'content of file');\n  \n    $zip-\u003eaddFromString('filename.txt', $file_content);\n    $zip-\u003eaddFromString('folder/file1.txt', $file_content);\n    $zip-\u003eaddFromString('folder/file2.txt', $file_content);\n\n\n    ```\n\n- Add multiple files/directories to zip:\n\n    ```php    \n    // using array as parameter\n    $zip-\u003eadd( array('/path/to/my/file1', '/path/to/my/file2');\n\n    // chaining methods\n    $zip-\u003eadd('/path/to/my/file1')-\u003eadd('/path/to/my/file2');\n\n    // declaring path\n    $zip-\u003esetPath('/path/to/my')-\u003eadd('file1')-\u003eadd('file2');\n\n    ```\n\n- Delete a file/directory from zip:\n\n    ```php    \n    $zip-\u003edelete('file');\n\n    ```\n\n- Delete multiple files/directories from zip:\n\n    ```php    \n    // using array as parameter\n    $zip-\u003edelete( array('file1', 'file2') );\n\n    // chaining methods\n    $zip-\u003edelete('file1')-\u003edelete('file2');\n\n    ```\n\n- List content of zip file\n\n    ```php    \n    $zip-\u003elistFiles();\n\n    ```\n\n- Close zip file\n\n    ```php    \n    $zip-\u003eclose();\n\n    ```\n\n### Additional methods\n\n- Skip hidden files while adding directories:\n\n    ```php    \n    // set mode\n    $zip-\u003esetSkipped('HIDDEN');\n\n    // get mode\n    $mode = $zip-\u003egetSkipped();\n\n    ```\n\n- Use password for zip extraction:\n\n    ```php    \n    // set password\n    $zip-\u003esetPassword('slartibartfast');\n\n    // get password\n    $password = $zip-\u003egetPassword();\n\n    ```\n\n- Use a mask != 0777 for created folders:\n\n    ```php    \n    // set mask\n    $zip-\u003esetMask(0644);\n\n    // get mask\n    $mask = $zip-\u003egetMask();\n\n    ```\n\n## ZipManager usage\n\nThe `\\ZanySoft\\Zip\\ZipManager` can handle multiple `ZanySoft\\Zip\\Zip` objects.\n\n- include the Zip and ZipManager class at top:\n```php\nuse ZanySoft\\Zip\\ZipManager;\nuse Zip;\n```\n\n### Basic operations\n\n- Init the manager and register Zips:\n\n    ```php    \n    // init manager\n    $manager = new ZipManager();\n\n    // register existing zips\n    $manager-\u003eaddZip( Zip::open('/path/to/my/file1.zip') )\n            -\u003eaddZip( Zip::open('/path/to/my/file2.zip') );\n\n    // register a new zip\n    $manager-\u003eaddZip( Zip::create('/path/to/my/file3.zip') );\n\n    ```\n\n- Basic zips management:\n\n    ```php    \n    // get a list of registered zips\n    $list = $manager-\u003elistZips();\n\n    // remove a zip\n    $manager-\u003eremoveZip($ZipObject);\n\n    // get a Zip\n    $zip = $manager-\u003egetZip(0);\n\n    ```\n\n- Add files to all zips:\n\n    ```php    \n    $manager = new ZipManager();\n\n    // register existing zips\n    $manager-\u003eaddZip( Zip::open('/path/to/my/file1.zip') )\n            -\u003eaddZip( Zip::open('/path/to/my/file2.zip') );\n\n    // register a new zip\n    $manager-\u003eaddZip( Zip::create('/path/to/my/file3.zip') );\n\n    ```\n\n- Extract zips:\n\n    ```php    \n    // separate content in folders\n    $extract = $manager-\u003eextract('/path/to/uncompressed/files', true);\n\n    // use a single folder\n    $extract = $manager-\u003eextract('/path/to/uncompressed/files', false);\n\n    // extract single file\n    $extract = $manager-\u003eextract('/path/to/uncompressed/files', false, 'file');\n\n    // extract multiple files\n    $extract = $manager-\u003eextract('/path/to/uncompressed/files', false, array('file1','file2'));\n\n    ```\n\n- Merge zips:\n\n    ```php    \n    // separate content in folders\n    $manager-\u003emerge('/path/to/output/file.zip', true);\n\n    // flatten files\n    $manager-\u003emerge('/path/to/output/file.zip', false);\n\n    ```\n\n- Close zips:\n\n    ```php    \n    $manager-\u003eclose();\n\n    ```\n\n### Additional methods\n\n- Declare path from which add files:\n\n    ```php    \n    // set path\n    $zip-\u003esetPath('/path/to/files');\n\n    // get path\n    $path = $zip-\u003egetPath();\n\n    ```\n\n- Use a mask != 0777 for created folders\n\n    ```php    \n    // set masks\n    $manager-\u003esetMask(0644);\n\n    // get masks\n    $mask = $manager-\u003egetMask();\n\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanysoft%2Flaravel-zip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzanysoft%2Flaravel-zip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanysoft%2Flaravel-zip/lists"}