smuuf/zip-reader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smuuf/zip-reader

最新稳定版本:1.0

Composer 安装命令:

composer require smuuf/zip-reader

包简介

A simple-to-use library for browsing and reading Zip files with friendly API.

README 文档

README

PHP tests

You just need to read Zip files in PHP? Say no more! 😎 This is a simple-to-use library for browsing and reading Zip files with friendly API. Just reading, nothing else (like creating or modifying Zip files - if you need that, look elsewhere).

Installation

composer require smuuf/zip-reader

ℹ️ This package uses the \ZipArchive class internally, so you need to have PHP extension Zip installed and enabled.

Usage

<?php

use \Smuuf\StrictObject;
use \Smuuf\ZipReader\ZippedDir;
use \Smuuf\ZipReader\ZippedFile;

require __DIR__ . '/../bootstrap.php';

// Loads some existing Zip file. (Or throws \Smuuf\ZipReader\Exc\ZipOpenError)
$zipReader = new ZipReader('/some/zipped/file.zip');

// This returns a dict array of items that are present in the root directory
// of the zip. For example:.
// [
// 	 'dir_a/' => ZippedDir object,
// 	 'dir_b/' => ZippedDir object,
// 	 'some_file_a.txt' => ZippedFile object,
// ]
$entries = $zipReader->getEntries();

// When browsing, directory path must have a trailing slash.
$item = $zipReader->browse('dir_a/'); // Instance of ZippedDir.
$item = $zipReader->browse('not_present_dir/'); // null
$item = $zipReader->browse('some_file_a.txt'); // Instance of ZippedFile.
$item = $zipReader->browse('not_present_dir/');  // null

// You can do nested browsing.
$dir = $zipReader->browse('dir_a/inner_dir/'); // Instance of ZippedDir.
$somefile = $zipReader->browse('dir_a/inner_dir/some_file.txt'); // Instance of ZippedFile.

// You can also browse further in the ZippedDir object.
// This will return ZippedFile that represents 'dir_a/inner_dir/some_other_file.txt'.
$someOtherFile = $dir->browse('some_other_file.txt');

// You can get contents of zipped file (done lazily).
$bytes = $someOtherFile->read();

// You can get stat array of a zipped file or a dir (done lazily).
// See https://www.php.net/manual/en/ziparchive.statname.php to see what
// items the stat array can  returns.
$fileStat = $someOtherFile->stat();
$dirStat = $dir->stat();

统计信息

  • 总下载量: 49
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固