aerni/zipper 问题修复 & 功能扩展

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

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

aerni/zipper

Composer 安装命令:

composer require aerni/zipper

包简介

Zip your Statamic assets on the fly

README 文档

README

Statamic Packagist version Packagist Total Downloads

Zipper

This addon provides a simple way to zip your Statamic assets on the fly.

Installation

Install the addon using Composer:

composer require aerni/zipper

Publish the config of the package (optional):

php please vendor:publish --tag=zipper-config

Basic Usage

To create a zip of your assets, you must call the zip tag followed by the variable containing your assets. The tag returns the URL to the route that handles creating the zip. The zip will be streamed without being saved to disk, but you may opt-in to save the file to disk for later use.

Somewhere in your content files:

images:
  - sega-genesis.jpg
  - snes.jpg

Somewhere in your views:

{{ zip:images }}

Filename

You may optionally pass a filename using the filename parameter. The filename defaults to the current timestamp when the Zip object is created. The example below binds the zip name to the page title.

{{ zip:images :filename="title" }}

Link Expiry

If you want to expire your links after a certain time, you can either set the expiry globally in the config or use the expiry parameter on the tag. The expiry is to be set in minutes. Note that the expiry on the tag will override the expiry in the config.

{{ zip:images expiry="60" }}

Cleanup Old References

Zipper saves an encrypted instance of the Zip class every time it returns a URL. This class is later retrieved and decrypted when a user downloads a zip. These reference files are stored in storage/zipper/{id}.

With time, the number of saved reference files will grow. To control this, Zipper provides a scheduled command that will delete old reference files daily. Just make sure that your Scheduler is running.

Cleanup Scopes

There are a couple of cleanup scopes to choose from in the config.:

Option Description
expired Only delete expired references files. This only affects references of zips that used the expiry option
all Delete all reference files, excluding unexpired files. This will delete references of expired zips and zips that didn't use the expiry option. It will not delete unexpired zips.
force Delete all reference files, including unexpired files. This will completely wipe all references.

Clean Command

You may also use the clean command to delete reference files at your will. The scope defaults to expired.

php please zipper:clean
php please zipper:clean --scope=all
php please zipper:clean --scope=force

Advanced Usage

You may also use this addon programmatically, as shown below.

use Aerni\Zipper\Zip;

// Prepare an array of Statamic assets, paths, or URLs.
$files = [
    Statamic\Assets\Asset,
    '/home/ploi/site.com/storage/app/assets/file_1.jpg',
    'https://site.com/path/to/file_2.jpg',
];

// Make a zip with the files above.
$zip = Zip::make($files);

// Set an optional filename. This defaults to the timestamp when the object was created.
$zip->filename('obi-wan-kenobi');

// Set an optional expiry time in minutes. This defaults to the expiry set in the config.
$zip->expiry(60);

// Get the URL that handles creating the zip.
$zip->url();

// Create a new zip or download a previously cached zip.
$zip->get();

aerni/zipper 适用场景与选型建议

aerni/zipper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 978 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「zip」 「zipper」 「statamic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 aerni/zipper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 aerni/zipper 我们能提供哪些服务?
定制开发 / 二次开发

基于 aerni/zipper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-16