aminkt/yii2-upload-manager
Composer 安装命令:
composer require aminkt/yii2-upload-manager
包简介
Upload manager system based and inspired from Wordpress upload manager.
README 文档
README
Yii2 Upload manage module.
To install this module add "aminkt/yii2-upload-anager" : ">=1.2.0" in your composer.json in your project.
Then add flowing lines into your application config:
'upload-manager' => [ 'class' => aminkt\uploadManager\UploadManager::class, 'uploadPath'=>Yii::getAlias("@frontendWeb")."/upload", 'uploadUrl'=> "/upload", 'baseUrl' => 'http://localhost:800', 'acceptedFiles'=>"*", 'userClass' => 'user/class/namespcae', 'fileClass' => 'file/class/namespcae', // Don't set this to use default active record. 'fileSearchClass' => 'file/search/class/namespcae', // Don't set this to use default search active record. ],
Then run below code to migrate up your modules:
Run migration if you are using defualt module models.
php yii migrate --migrationPath="@vendor/aminkt/yii2-upload-manager"
If you want to edit your files, open
['uploadManager/default/index']in your browser.
How use upload manager widget?
Add flowing lines into your view file to load upload manager widget:
<?php echo \aminkt\uploadManager\components\UploadManager::widget([ 'id'=>'upload-user-pic-'.$model->id, 'model'=>$model, 'attribute'=>'picture', 'titleTxt'=>'تصویر ربات را کنید.', 'helpBlockEnable'=>false, 'showImageContainer'=>'#avatar-'.$model->id, 'showImagesTemplate'=>"<img src='{url}' class='img-responsive'>", 'btnTxt'=>'<i class="fa fa-edit"></i>' ]); echo Html::hiddenInput('target', $model->id, ['class'=>'target']); ?> <div id="avatar-<?= $model->id ?>"></div>
Use Upload manager api to upload and fetch files
First add flowing routes to your api url manager:
[
'class' => 'yii\rest\UrlRule',
'pluralize' => false,
'controller' => ['v2/upload' => 'uploadManager/v1/upload'],
'extraPatterns' => [
'GET load/<id:\d+>' => 'load',
]
],
Top code means that use uploadManager api version 1 from v2/upload route. Flowing routes now available:
GET /v2/upload // List of all files that user uploaded.
GET /v2/upload/[id] // Detail of one single file.
GET /v2/upload/load/[id] // Return file content of one single file by id
DELETE /v2/upload/[id] // Delete a single file from server.
POST /v2/upload // Upload a new file.
Notice:
- All request except load and view shoud use at least one auth method to authrize user.
- In upload route don't set content-type in header but in others you can.
- In upload route send file as post, file multi part and file name is better to be 'file'
Warning: Cross origin is enabled by default. if you have any problem with this please report it.
Advanced configuration
If you want implement your own models or search model or you wnat use Mongo db database you should flow below instractions.
- Create your models.
- Implement
\aminkt\uploadManager\interfaces\FileInterface - If you want use default File constant implement
\aminkt\uploadManager\interfaces\FileConstantsInterfaceor not create your own constants named like defined interface. - Config you module like said in first part and define
fileClassandfileSearchClass - You can use
\aminkt\uploadManager\traits\FileTraitto implement some regular methods that defined inFileInterface
If you wnat use mongodb active record you can just change
fileClassandfileSearchClassdiscribed in configuration part to use mongodb version as\aminkt\uploadManager\models\mongo\Fileand\aminkt\uploadManager\models\mongo\FileSearch
aminkt/yii2-upload-manager 适用场景与选型建议
aminkt/yii2-upload-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 397 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 11 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「manager」 「module」 「upload」 「yii」 「upload manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aminkt/yii2-upload-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aminkt/yii2-upload-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aminkt/yii2-upload-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Laravel Media Popup to upload/view the files
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
KCFinder web file manager
Publish / Subscribe / Event Manager
Yii2 module to manage website content. Kind of a CMS...
统计信息
- 总下载量: 397
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2017-11-20