定制 arz-cle/mime-guard 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

arz-cle/mime-guard

Composer 安装命令:

composer require arz-cle/mime-guard

包简介

Statamic addon for granular MIME type management with hierarchical rules

README 文档

README

Stop trusting file extensions. Validate what's actually inside.

Statamic 6.x PHP 8.2+ License MIT Tests

The problem

A .jpg file can contain PHP code. A .png can be a ZIP archive. File extensions are trivial to fake, and Statamic doesn't inspect file contents by default. One malicious upload is all it takes.

MIME Guard reads the actual file bytes to determine what a file really is, then enforces your rules.

Features

  • Real MIME detection -- uses magic bytes (finfo), not file extensions
  • Hierarchical rules -- Global > Container > Blueprint, most specific wins
  • Wildcards -- image/*, video/*, document/*, archive/*
  • Native CP interface -- tabs, toggle switches, built with Statamic 6 components
  • Blocked upload logging -- MIME type, filename, user, and container
  • Secure defaults -- SVG, PDF, archives, and binaries blocked out of the box

Installation

composer require arz-cle/mime-guard

Optionally publish the config file:

php artisan vendor:publish --tag=mime-guard-config

Quick start

Via the Control Panel

Navigate to Tools > MIME Guard. Four tabs let you configure everything visually:

Tab Purpose
Global Block MIME types across all uploads
Containers Override rules per asset container
Blueprints Override rules per collection blueprint
Help Rule hierarchy and wildcard reference

Via config file

// config/mime-guard.php

return [
    'restricted_by_default' => [
        'application/octet-stream',
        'application/zip',
        'image/svg+xml',
        'application/pdf',
    ],

    'containers' => [
        'documents' => [
            'allow' => ['application/pdf'],
        ],
        'gallery' => [
            'allow' => ['image/*'],
            'deny'  => ['image/svg+xml'],
        ],
    ],

    'blueprints' => [
        'products::3d_viewer' => [
            'allow' => ['model/stl', 'model/gltf-binary'],
        ],
    ],

    'logging' => [
        'enabled' => true,
        'channel' => 'stack',
    ],
];

How rules work

Rules cascade from general to specific. Each level can allow, deny, or inherit: false to start fresh.

Global          Blocks SVG, PDF, ZIP everywhere
  Container     Allows PDF in "documents" container
    Blueprint   Allows STL in "products::3d_viewer" blueprint

A type allowed at a more specific level overrides a global block. A type denied at a more specific level overrides a parent allow.

Wildcards

Pattern Matches
image/* JPEG, PNG, GIF, WebP, SVG, etc.
video/* MP4, WebM, QuickTime, etc.
document/* PDF, Word, Excel, PowerPoint, TXT, RTF
archive/* ZIP, RAR, 7Z, TAR, GZIP

Requirements

Dependency Version
Statamic 6.x
PHP 8.2+
Laravel 11.x / 12.x

License

MIT -- see LICENSE for details.

Built by Clement Arzoumanian for Statamic.

arz-cle/mime-guard 适用场景与选型建议

arz-cle/mime-guard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 arz-cle/mime-guard 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-30