定制 kenarkose/transit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Build Status Total Downloads Latest Stable Version License

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.

  1. Pull this package in through Composer.

    {
        "require": {
            "kenarkose/transit": "~2.1"
        }
    }
  2. In order to register Transit Service Provider add 'Kenarkose\Transit\Provider\TransitServiceProvider' to the end of providers array in your config/app.php file.

    'providers' => array(
    
        'Illuminate\Foundation\Providers\ArtisanServiceProvider',
        'Illuminate\Auth\AuthServiceProvider',
        ...
        'Kenarkose\Transit\Provider\TransitServiceProvider',
    
    ),
  3. 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.

  4. 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 aliases array in your config/app.php file.

    'aliases' => array(
    
        'App'        => 'Illuminate\Support\Facades\App',
        'Artisan'    => 'Illuminate\Support\Facades\Artisan',
        ...
        'Downloader'   => 'Kenarkose\Transit\Facade\Downloader',
        'Uploader'     => 'Kenarkose\Transit\Facade\Uploader',
    
    ),
  5. 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.php path. 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.

  6. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 kenarkose/transit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 793
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 21
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-04-15