teepluss/up2
Composer 安装命令:
composer require teepluss/up2
包简介
UP2 is a file uploader with polymorphic relations.
README 文档
README
For Laravel 4, please use the v1.x branch!
UP2 is a file uploader with polymorphic relations.
Installation
To get the lastest version of Theme simply require it in your composer.json file.
"teepluss/up2": "dev-master"
You'll then need to run composer install to download it and have the autoloader updated.
Once Theme is installed you need to register the service provider with the application. Open up app/config/app.php and find the providers key.
'providers' => [
Teepluss\Up2\Up2ServiceProvider::class
]
UP2 also ships with a facade which provides the static syntax for creating collections. You can register the facade in the aliases key of your app/config/app.php file.
'aliases' => [
'UP2' => Teepluss\Up2\Facades\Up2::class
]
Publish using artisan CLI.
php artisan vendor:publish --provider="Teepluss\Up2\Up2ServiceProvider"
Migrate tables.
php artisan migrate
Usage
The uploader configuration is located at app/config/up2.php. In this file you may specify which uploader driver you would like used by default throughout your application. UP2 supports Local and S3.
'drivers' => array( 'local' => array( 'baseUrl' => url(''), 'baseDir' => path_public(), ), 's3' => array( 'key' => '', 'secret' => '', 'region' => 'ap-southeast-1', 'bucket' => 'teeplus', ), ),
Then you have to create a morph method for your model that want to use "UP2".
use Teepluss\Up2\Up2Trait; use Illuminate\Database\Eloquent\Model; class Blog extends Model { use Up2Trait; public function ..... }
Now you able to use "UP2" for uploading file.
Upload file and resizing.
// Return an original file meta. UP2::upload(Blog::find(1), Input::file('userfile'))->getMasterResult(); UP2::upload(User::find(1), Input::file('userfile'))->getMasterResult(); // Return all results files uploaded including resized. UP2::upload(Product::find(1), Input::file('userfile'))->resize()->getResults(); // If you have other fields in table attachments. UP2::upload(User::find(1), Input::file('userfile'), array('some_id' => 999))->getMasterResult(); // UP2 can upload remote file. UP2::inject(array('remote' => true))->upload(User::find(1), 'http://domain.com/image.png', array('some_id' => 999))->getResults();
Upload without model.
UP2::upload(null, Input::file('userfile'))->getMasterResult();
Inject configuration.
UP2::inject(array('subpath' => 'uploads/products'))->upload(Blog::find(1), Input::file('userfile'))->getMasterResult();
Look up a file path.
$blogs = Blog::with('attachments')->get(); foreach ($blogs as $blog) { foreach ($blog->attachments as $attachment) { echo UP2::lookup($attachment->id); // or lookup with scale from config. echo UP2::lookup($attachment->id)->scale('l'); } }
Remove file(s) from storage.
$attachmentId = 'b5540d7e6350589004e02e23feb3dc1f'; // Remove a single file. UP2::remove($attachmentId); // Remove all files including resized. UP2::remove($attachmentId, true);
Support or Contact
If you have some problem, Please contact teepluss@gmail.com
teepluss/up2 适用场景与选型建议
teepluss/up2 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 730 次下载、GitHub Stars 达 12, 最近一次更新时间为 2014 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「upload」 「resize」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 teepluss/up2 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 teepluss/up2 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 teepluss/up2 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Image cache
The lireincore/imgcache integration for the Yii2 framework
Laravel Media Popup to upload/view the files
NinjaImg PHP SDK.
Alfabank REST API integration
统计信息
- 总下载量: 730
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-01-17