定制 namest/drive 二次开发

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

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

namest/drive

最新稳定版本:v0.1

Composer 安装命令:

composer require namest/drive

包简介

README 文档

README

Provide an elegant way to interact with upload & process uploaded file feature.

Note: The package is only support Laravel 5

Installation

Step 1: Install package

composer require namest/drive

Step 2: Register service provider in your config/app.php

return [
    ...
    'providers' => [
        ...
        'Namest\Drive\DriveServiceProvider',
    ],
    ...
];

Step 3: Publish package configs. Open your terminal and type:

php artisan vendor:publish --provider="Namest\Drive\DriveServiceProvider"

Step 4: Edit your appropriate configurations in config/drive.php:

Step 6: Read API below and start happy

API

Accept file upload (validate,...)

$file = Drive::accept($input_name);

Validation

// Set up validation rules in config file use laravel validation rules
return [
    ...
    'rules' => [
        'max:2048', // Kilobytes
        // Whatever you want
    ],
    ...
];

Throws ValidationException when failed validation.

Save file (without editing)

$nomal = $file->save();
$large = $file->save('-large'); // With file name suffix

Edit image file via method chaining

// Recipe: $file-><intervention/image method>($parameters)
$small = $file->crop($width, $height, $x, $y)
              ->blur($percent)
              ->save('-small');

Edit image use profile declare in drive.profiles config

$avatar = $file->profile('avatar')->save();

Auto edit file by profile for particular upload type

// For example: apply `avatar` profile with every uploaded images.
// Edit in `drive` config
return [
    ...
    'default_profiles' => [
        'image' => ['avatar'],
        'video' => [],
    ],
    ...
];

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

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