kenarkose/transit
最新稳定版本:2.1.3
Composer 安装命令:
composer require kenarkose/transit
包简介
Easy file uploading and downloading for Laravel 5
README 文档
README
Easy file uploading and downloading for Laravel 5.
Features
- Compatible with Laravel 5
- Clean API for uploading and downloading files
- Automated(optional) validation while uploading files
- Customization options for file storage, model and validation
- Generators for model and migration
- Deleting uploaded files
- A phpunit test suite for easy development
Installation
Installing Transit is simple.
-
Pull this package in through Composer.
{ "require": { "kenarkose/transit": "~2.1" } } -
In order to register Transit Service Provider add
'Kenarkose\Transit\Provider\TransitServiceProvider'to the end ofprovidersarray in yourconfig/app.phpfile.'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', ... 'Kenarkose\Transit\Provider\TransitServiceProvider', ),
-
In order to persist the uploaded file information, you have to create a migration for the 'Kenarkose\Transit\File\File' model, which is the default model used for database persistence. To do so, use the following command.
php artisan transit:migration
Do not forget to migrate the database when prompted to or after modifying the generated migration file.
-
You may access the services provided by Transit by using the supplied Facades or from the service container.
// Symfony\Component\HttpFoundation\File\UploadedFile $uploadedFile Uploader::upload($uploadedFile); app()->make('transit.upload')->upload($uploadedFile); // Kenarkose\Transit\Contract\Downloadable $fileModel return Downloader::download($fileModel); return app()->make('transit.download')->download($fileModel);
In order to register the Facades add following the facades to the end of
aliasesarray in yourconfig/app.phpfile.'aliases' => array( 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', ... 'Downloader' => 'Kenarkose\Transit\Facade\Downloader', 'Uploader' => 'Kenarkose\Transit\Facade\Uploader', ),
-
Finally, you may configure the default behaviour of Transit by publishing and modifying the configuration file. To do so, use the following command.
php artisan vendor:publish
Than, you will find the configuration file on the
config/transit.phppath. Additional information about the options can be found in the comments of this file. All of the options in the config file are optional, and falls back to default if not specified; remove an option if you would like to use the default. -
Please check the tests and source code for further documentation.
Custom Model
You may need a custom model for your case; for instance, when you wish to use Ownable. You can generate a new model for Transit with the following command.
php artisan transit:model
If you do not wish to use the generator, make sure that your model implements Kenarkose\Transit\Contract\Uploadable interface.
Keep in mind that if you would like to use a custom model you should publish the configuration file by using php artisan vendor:publish command and change the class path for model in the configuration file as well. Alternatively you may configure the UploadService on runtime by using the the modelName method. It is required only for UploadService that you register the model name:
Uploader::modelName('Custom\Uploadable\Model'); // or app()->make('transit.upload')->modelName('Custom\Uploadable\Model');
You may use separate models for Upload and Download services as well as deleting files.
But you must implement Kenarkose\Transit\Contract\Uploadable, Kenarkose\Transit\Contract\Downloadable and Kenarkose\Transit\Contract\Deletable interfaces respectively. Furthermore, you may use Kenarkose\Transit\File\Uploadable, Kenarkose\Transit\File\Downloadable and Kenarkose\Transit\File\Deletable traits for providing required functionality to Eloquent models.
License
Transit is released under MIT License.
kenarkose/transit 适用场景与选型建议
kenarkose/transit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 793 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「upload」 「laravel」 「download」 「transit」 「laravel5」 「kenarkose」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kenarkose/transit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kenarkose/transit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kenarkose/transit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The NzoFileDownloaderBundle is a Symfony Bundle used to Download all types of files from servers and Web applications safely and with ease. You can also read/show the file content in the Web Browser.
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Adds a download link next to assets
Laravel Media Popup to upload/view the files
Based on Youtube-dl and FFMPEG. Downloads Youtube and Facebook videos from the url.
PHP library to efficiently stream contents from an AWS S3 bucket or folder as a zip file
统计信息
- 总下载量: 793
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-15