Download the PHP package goletter/hyperf-archive without Composer
On this page you can find all versions of the php package goletter/hyperf-archive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package hyperf-archive
Hyperf Archive
Hyperf 多文件 ZIP 打包扩展,支持本地文件、内存内容、filesystem 磁盘,以及直接下载 / 上传存储。
安装
配置文件发布到 config/autoload/archive.php。
依赖 PHP 扩展:ext-zip。
配置
使用
链式 API(推荐)
辅助函数:
打包整个文件夹
通过 ArchiverInterface 也可以直接传目录数组:
注入 ArchiverInterface
下载地址配置
config/autoload/archive.php:
{path} 会被替换为上传后的远端路径。如需 OSS 签名链接,可在业务中实现 ArchiveUrlResolverInterface 并绑定到容器。
Controller 示例
$files 可为本地路径字符串,或:
输出方式
| 方法 | 说明 |
|---|---|
download() |
设置 Content-Disposition: attachment 直接下载 |
create() |
返回本地临时 ZIP 绝对路径 |
upload() |
上传到 hyperf/filesystem 磁盘并返回远端路径 |
store() |
上传后返回 ArchiveResult(含 url 下载地址) |
与 goletter/hyperf-server 的 ResponseFormatMiddleware 兼容:attachment 响应会透传,不会被包装成 JSON。
安全说明
- ZIP 内路径会过滤
../,避免目录穿越 - 目录打包会跳过符号链接指向目录外的文件
- 默认跳过隐藏文件/目录(以
.开头) - 请在业务层校验用户对每个文件的访问权限,不要直接信任前端传入的绝对路径
- 通过
max_files/max_total_size限制单次打包规模
License
MIT
All versions of hyperf-archive with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
ext-zip Version *
hyperf/context Version ~3.1.0
hyperf/contract Version ~3.1.0
hyperf/coroutine Version ~3.1.0
hyperf/filesystem Version ~3.1.0
hyperf/http-server Version ~3.1.0
hyperf/support Version ~3.1.0
psr/container Version ^1.0 || ^2.0
ext-zip Version *
hyperf/context Version ~3.1.0
hyperf/contract Version ~3.1.0
hyperf/coroutine Version ~3.1.0
hyperf/filesystem Version ~3.1.0
hyperf/http-server Version ~3.1.0
hyperf/support Version ~3.1.0
psr/container Version ^1.0 || ^2.0
The package goletter/hyperf-archive contains the following files
Loading the files please wait ...