blax-software/laravel-files
Composer 安装命令:
composer require blax-software/laravel-files
包简介
Universal Laravel file management system — upload, optimize, serve, and attach files to any model.
README 文档
README
Laravel Files
A universal, plug-and-play file management system for Laravel. Upload, optimize, serve, and attach files to any Eloquent model — with disk-agnostic storage, automatic image optimization, chunked uploads, and a built-in warehouse endpoint.
Features
- Attach files to any model — polymorphic MorphToMany relationship via the
HasFilestrait - Role-based attachments — tag files as
avatar,gallery,document, etc. using theFileLinkTypeenum or custom strings - Disk-agnostic — works with any Laravel filesystem disk (local, S3, GCS, …)
- Automatic image optimization — on-the-fly resizing and WebP conversion via spatie/image
- Chunked uploads — upload large files in pieces with real-time progress broadcasting
- Warehouse endpoint — a single route that resolves and serves any file by UUID, encrypted ID, or asset path
- UUID primary keys — every file gets a unique, non-sequential identifier
- Artisan cleanup — remove orphaned files that are no longer attached to any model
Quick Start
composer require blax-software/laravel-files
Publish the config and migrations:
php artisan vendor:publish --tag=files-config php artisan vendor:publish --tag=files-migrations php artisan migrate
Add the trait to any model:
use Blax\Files\Traits\HasFiles; class User extends Model { use HasFiles; }
Attach a file:
use Blax\Files\Enums\FileLinkType; $user = User::find(1); // Upload and attach in one call $file = $user->uploadFile($request->file('avatar'), as: FileLinkType::Avatar, replace: true); // Get the avatar back $avatar = $user->getAvatar(); echo $avatar->url; // → /warehouse/019d8ab8-… echo $avatar->size_human; // → "2.4 MB"
Documentation
| Guide | Description |
|---|---|
| Installation | Requirements, installation, configuration |
| Attaching Files | The HasFiles trait, roles, attach/detach, reordering |
| File Operations | Creating files, reading/writing contents, duplication, scopes |
| Uploading | Single uploads, chunked uploads, progress events |
| Serving Files | The Warehouse, inline responses, downloads |
| Image Optimization | On-the-fly resizing, WebP, quality control |
| Configuration | Full reference for config/files.php |
| Artisan Commands | files:cleanup and maintenance |
Optional Dependencies
| Package | Purpose |
|---|---|
spatie/image ^3.8 |
Image optimization and resizing |
blax-software/laravel-roles |
Access control on the warehouse endpoint |
blax-software/laravel-websockets |
Real-time chunk upload progress via WebSockets |
Testing
composer test # or ./vendor/bin/phpunit
License
MIT — see LICENSE for details.
Star History
blax-software/laravel-files 适用场景与选型建议
blax-software/laravel-files 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「media」 「image」 「upload」 「files」 「optimization」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blax-software/laravel-files 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blax-software/laravel-files 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blax-software/laravel-files 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
Laravel Media Popup to upload/view the files
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 37
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-17