mitsuki/storage
Composer 安装命令:
composer require mitsuki/storage
包简介
A flexible and framework-agnostic storage library for managing structured records, originally built for the Mitsuki PHP framework and usable in any PHP application.
关键字:
README 文档
README
Mitsuki Storage is a flexible, framework-agnostic PHP library for managing file storage and structured records. Originally built for the Mitsuki framework, it provides a clean and secure abstraction over the Symfony Filesystem component to handle uploads, persistence, and file management in any PHP application.
🚀 Features
- Secure Uploads: Automatic unique filename generation to prevent collisions and overwrites.
- Fluent Directory Management: Automatically handles recursive directory creation.
- Standardized Exceptions: Robust error handling with custom
FileExceptionandFileNotFoundException. - Framework Agnostic: Integration-ready for Laravel, Symfony, Slim, or any vanilla PHP project.
- Fully Tested: High-quality code base tested with Pest PHP.
📦 Installation
Install the package via Composer:
composer require mitsuki/storage
🛠 Usage
Initialization
To start, you need a base directory where files will be stored and an instance of Symfony's Filesystem.
use Mitsuki\Storage\Storage; use Symfony\Component\Filesystem\Filesystem; $baseDir = __DIR__ . '/storage'; $storage = new Storage(new Filesystem(), $baseDir);
Storing an Uploaded File
The store method expects a Symfony\Component\HttpFoundation\File\UploadedFile (standard in many frameworks).
try { // Stores file in storage/avatars/user-1/ with a secure unique name $absolutePath = $storage->store('avatars/user-1', $uploadedFile); echo "File saved at: " . $absolutePath; } catch (FileException $e) { echo "Upload failed: " . $e->getMessage(); }
Retrieving and Checking Files
// Get the absolute path of a relative file try { $path = $storage->getFile('avatars/user-1/photo.jpg'); } catch (FileNotFoundException $e) { // Handle error } // Simple existence check if ($storage->exists('documents/report.pdf')) { // Logic here... }
Deleting Files
try { $storage->delete('temp/old-file.txt'); } catch (FileNotFoundException $e) { // File not found }
🧪 Testing
The library is tested using Pest PHP.
# Install development dependencies composer install # Run the test suite vendor/bin/pest
📄 API Reference
Storage Class
| Method | Argument | Description |
|---|---|---|
store() |
string $path, UploadedFile $file |
Validates, secures, and moves an upload. Returns full path. |
getFile() |
string $path |
Resolves a relative path to an absolute path. |
exists() |
string $path |
Returns true if the path exists. |
createDir() |
string $path |
Recursively creates directories. |
delete() |
string $path |
Removes a file or directory. |
👤 Author
Zgenius Matondo
- GitHub: @zgeniusecoders
- Email: zgeniusecoders@gmail.com
⚖️ License
This project is licensed under the MIT License - see the LICENSE file for details.
mitsuki/storage 适用场景与选型建议
mitsuki/storage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「persistence」 「php」 「storage」 「backend」 「modular」 「framework-agnostic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mitsuki/storage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mitsuki/storage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mitsuki/storage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
This bundle provides tools to build persistence-agnostic storage layer.
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
Propel2 is an open-source Object-Relational Mapping (ORM) for PHP 5.5 and up.
Kinikit - PHP Application development framework MVC component
A library providing abstract implementations of various persistence layers based on JSON API relational resource concepts.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-25