jdz/mediamanager
Composer 安装命令:
composer require jdz/mediamanager
包简介
JDZ media manager
README 文档
README
Framework-agnostic media utilities: file/image upload with automatic resize, and media-folder trees for pickers (images / documents).
Installation
composer require jdz/mediamanager
Upload
JDZ\MediaManager\Upload validates an uploaded file (mime, extension, weight), slugs the filename, moves it into place and downscales large images in-place (GD via Imagine, EXIF autorotate).
use JDZ\MediaManager\Upload; $upload = new Upload(); $upload->path = '/path/to/public/media/photos/'; $upload->overwrite = false; $upload->maxPictureLongSide = 1800; $upload->upload($request->files->get('file')); // Symfony UploadedFile echo $upload->filename; // slugged, unique, resized if needed
Throws \Exception on unauthorized mime, oversized file or move failure.
Trees
ImageTree builds a nested folders/files structure; DocumentTree builds a flat list with per-type icons. Both skip entries whose basename starts with _, and accept ignore lists.
use JDZ\MediaManager\Tree\ImageTree; use JDZ\MediaManager\Tree\DocumentTree; $images = (new ImageTree()) ->setBasePath($publicPath . 'media/') ->setBaseUrl('../media/') ->setIgnoreFolders(['template']) ->setIgnoreFiles(['share.jpg']) ->getTree(); // ['folders' => [['label','path','files' => [...]], ...], 'files' => [['url','id','title','ext'], ...]] $documents = (new DocumentTree()) ->setBasePath($publicPath . 'media/') ->setBaseUrl('../media/') ->getTree(); // [['id','title','text','icon','url','ext'], ...]
Paths are normalized to forward slashes on every platform (Symfony\Filesystem\Path::normalize).
Tests
composer test
License
MIT — see LICENSE.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-13