evolutasrl/dropzone-bundle
Composer 安装命令:
composer require evolutasrl/dropzone-bundle
包简介
Symfony DropzoneBundle
关键字:
README 文档
README
The DropzoneBundle adds support for a direct S3 upload in Symfony2 forms. It provides a form type for sending files directly to your Amazon AWS S3 bucket without touch your webserver.
Read more about this technique in Aws website.
Features include:
- Single file upload
- Multiple file upload
This bundle is well unit tested by phpspec.
Installation
Installation is a quick (I promise!) 4 step process:
- Download DropzoneBundle using composer
- Enable the Bundle
- Configure the DropzoneBundle
- Javascript and css
###Step 1: Download DropzoneBundle using composer
Require the bundle with composer:
$ composer require evoluta/dropzone-bundle "1.0.x-dev"
Composer will install the bundle to your project's vendor/evoluta/dropzone-bundle directory.
###Step 2: Enable the bundle
Enable the bundle in the kernel::
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Evoluta\DropzoneBundle\EvolutaDropzoneBundle(),
// ...
);
}
###Step 3: Configure DropzoneBundle The next step is to configure the bundle to work with the specific needs of your application.
Add the following configuration to your parameters.yml file.
dropzone_endpoint: //s3-eu-west-1.amazonaws.com/
dropzone_accessKey: <aws_accesskey>
dropzone_secret: <aws_secret>
dropzone_bucket: <aws_bucket>
You can override configurations from parameters.yml in your type usage.
Add the following configuration to your config.yml file.
evoluta_dropzone:
endpoint: "%dropzone_endpoint%"
accessKey: "%dropzone_accessKey%"
secret: "%dropzone_secret%"
bucket: "%dropzone_bucket%"
###Step 4: Add twig configuration Add in your config.yml file the follow line
- 'EvolutaDropzoneBundle:Form:fields.html.twig'
Your config twig area will be like that
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
globals:
_guardian_company: "@guardian.company.identity_factory"
form_themes:
- bootstrap_3_layout.html.twig
- 'EvolutaDropzoneBundle:Form:fields.html.twig'
###Step 5: Javascript and css Todo: describe assets dump and declare in main template.
Usage - upload single
With this bundle, is available for you a new form field type called dropzoneS3File.
This field type extends the symfony default url field type.
class DropzoneController extends Controller
{
public function testAction(Request $request)
{
// ...
$form = $this->createFormBuilder()
->add(
'task1',
'dropzoneS3File'
)
->add(
'task2',
'dropzoneS3File',
array(
'acceptedFiles' => 'image/*',
'directory' => 'images/sub1/sub2'
)
)
->getForm();
// ...
}
}
###Options ####Endpoint You can override global aws endpoint configuration for this field.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'endpoint' => '//s3-eu-west-1.amazonaws.com/',
)
)
####AccessKey You can override global accessKey configuration for this field.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'accessKey' => '<your accessKey>',
)
)
####Secret You can override global secret configuration for this field.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'secret' => '<your secret>',
)
)
####Bucket You can override global secret configuration for this field.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'bucket' => '<your bucket>',
)
)
####Acl Amazon S3 supports a set of predefined grants, known as canned ACLs. Each canned ACL has a predefined a set of grantees and permissions. You ca read more here
You can override global all configuration for this field.
You can use one of these options:
- private
- public-read
- public-read-write
- authenticated-read
- bucket-owner-read
- bucket-owner-full-control
The default value is public-read
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'all' => 'public-read',
)
)
####Directory The sub directory where to put file. The default value is null.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'directory' => 'images/sub1/sub2'
)
)
####AcceptedFiles The default implementation checks the file's mime type or extension against this list. This is a comma separated list of mime types or file extensions. Eg.: image/*,application/pdf,.psd. The default config allow to upload every kind of file.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'acceptedFiles' => 'image/*'
)
)
####ExpireAt The expiration element specifies the expiration date and time of the POST policy. Indicate how long the user can wait from page loading to finish upload. It expects to be given a string containing an English date format. You can use this keywords:
- now
- +1 hour
- +4 hours
- +1 day
- +5 days
- +1 week
- +1 week 2 days 4 hours 2 seconds
- next Thursday
- last Monday
Internal this function use strtotime read more in php website.
$form = $this->createFormBuilder()
->add(
'File upload',
'dropzoneS3File',
array(
'expireAt' => '+1 hour'
)
)
Usage - upload multiple
Still in progress. Please help us!
###TODO
- configure aws
License
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
About
DropzoneBundle is a evolutasrl initiative coded by brainrepo proudly made in Sardinia with love :).
Reporting an issue or a feature request
Issues and feature requests are tracked in the Github issue tracker.
When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.
evolutasrl/dropzone-bundle 适用场景与选型建议
evolutasrl/dropzone-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 173 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 10 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「file upload」 「dropzone」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 evolutasrl/dropzone-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 evolutasrl/dropzone-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 evolutasrl/dropzone-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
Drag and drop file upload for ACF-Fields.
Laravel Media Popup to upload/view the files
PMVC Plugin for File information
Mapper for accessing resources in KWCMS
Text file manipulation
统计信息
- 总下载量: 173
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-26