zotyo/u-filer
Composer 安装命令:
composer require zotyo/u-filer
包简介
Manage file uploads
README 文档
README
The package offers you a more convenient way to manage file uploads in Laravel.
Instead of reinventing the wheel at each file-upload managing your uploaded files will be easy and consistent.
- Upload file with unique name, without concurrency problems.
- Store client-side informations of uploaded files in FileDescriptors.
- File object for ease of managing files in your application.
- Helper trait for your Eloquent models to easily create accessors/mutators.
- User friendly replacement of regular <input type="file"/>
By default the package is configured to upload images but you can use for any mime type.
Installation
composer require "zotyo/u-filer"
After downloading the package, add PackageServiceProvider to the providers array of your config/app.php
Zotyo\uFiler\PackageServiceProvider::class
Finally you should publish config of the package with some examples.
php artisan vendor:publish --provider="Zotyo\uFiler\PackageServiceProvider"
Usage
Several components come with the package to reduce the effort of implementing a proper file-upload.
File-input
You can publish a file-input.vue component into your /resources/assets/js/components folder. Modify the component so it would fit into your design.
<div class="form-group"> <label for="avatar">Avatar</label> <file-input id="avatar" v-model="user.avatar"></file-input> </div>
The vue-component uploads the file to a specific endpoint.
Note: You can avoid VueJS at all if you want so.
Endpoint(Route+Controller)
The package provides an Http endpoint for uploading files. You can disable the endpoint int the configuration file. If you would like to define your custom endpoint, you can still reuse UploadControllerTrait.
Method | URI | Name | Action
POST | upload | upload | Zotyo\uFiler\Http\UploadController@upload
Eloquent
The HasFile trait provides methods so you can easily create accessors/mutators in you model. In the following example User's avatar is a file.
<?php namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; use Zotyo\uFiler\HasFile; class User extends Authenticatable { use HasFile; protected $fillable = ['avatar']; protected $appends = ['avatar']; public function getAvatarAttribute() { return $this->getFile('avatar'); } public function setAvatarAttribute($value) { $this->setFile('avatar', $value); } }
Validation
Don't forget to validate files when submitting your entities. The package provides the verify-file-by-token validation rule to avoid hijacking of files.
<?php namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class UserFormRequest extends FormRequest { public function rules() { return [ 'avatar' => 'required|verify-file-by-token' ]; } }
zotyo/u-filer 适用场景与选型建议
zotyo/u-filer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 51 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「file」 「upload」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zotyo/u-filer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zotyo/u-filer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zotyo/u-filer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Laravel Media Popup to upload/view the files
PMVC Plugin for File information
Mapper for accessing resources in KWCMS
Text file manipulation
KCFinder web file manager
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-17