coshi/mediabundle
Composer 安装命令:
composer require coshi/mediabundle
包简介
Simple Media bundle
README 文档
README
MediaBundle - for Symfony 2
Provides
This bundle provides a service and base entity class. Events are dispached after each media manager service action.
Setup
-
Create your media bundle for example AcmeMediaBudle - [optional step - only creation of entity is required]
-
Create Media entity which extends Coshi\MediaBundle\Entity\Media, add id column and mapping of your choice [ if bundle had been created create entity in that bundle ]
-
Add CoshiMediaBundle configuration to your appliaction's config.yml see config reference. Note that you have to create media_path in your web_root and give them proper permissions
-
Add CoshiMediaBundle to your AppKernel.php
-
Update your database schema
-
Add desired entities which have attached media and implement interfaces Coshi\MediaBundle\Model\MediaInterface for desired entity
-
Now you can use coshi_media.media_manager service to perform file upload as simple as
$this->get('coshi_media.media_manager')->create($uploadedFileObject); $this->getDoctrine()->getManager()->flush();
Minimal configuration for storing files on local filesystem
coshi_media:
media_class: AppBundle\Entity\Media
#Adapters definiton
adapters:
local:
directory: media
create: true
filesystems:
local:
adapter: local
filesystem_default: local
Currentluy only Amazon S3 and Local filesystem are supported.
Configuration reference
coshi_media:
media_class: Webfit\MO\MediaBundle\Entity\Media
#Adapters definiton
adapters:
local:
directory: media_upload_delete_work
create: true
aws_s3:
service_id: aws_s3.client #name of amazon service
bucket_name: test-mediabundle
options:
directory: media_bundle_adapter_upload
#Filesystems/storage definition
filesystems:
local:
adapter: local
amazon:
adapter: aws_s3
#Optional parameter
filesystem_default: amazon
Twig Extension
This bunlde provides simple extension to render a path to media in Twig
{{ coshi_media_url(media) }}
Where of course media is a instance of mapped media class
Events
Bundle generates couple events they are defined in Coshi\MediaBundle\MediaEvents Events occurs on create of medium, update and delete. This is the way to extend bundle functionality.
MediaEvents::CREATE_MEDIA
MediaEvents::UPDATE_MEDIA
MediaEvents::DELETE_MEDIA
coshi/mediabundle 适用场景与选型建议
coshi/mediabundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.04k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「media」 「uploads」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 coshi/mediabundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 coshi/mediabundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 coshi/mediabundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Pop Http Component for Pop PHP Framework
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
A very simple yet useful helper class to handle PHP file uploads.
Wordpress S3 Uploads Drop In
An HTML5 upload field for Silverstripe 4, including editable form fields for silverstripe/userforms
Laravel Media Popup to upload/view the files
统计信息
- 总下载量: 2.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-01-05