承接 sokil/php-upload 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sokil/php-upload

Composer 安装命令:

composer require sokil/php-upload

包简介

File uploader

README 文档

README

Latest Stable Version Build Status Coverage Status

Installation

You can install library through Composer:

{
    "require": {
        "sokil/php-upload": "dev-master"
    }
}

Related packages

Quick start

First create HTML:

    <input type="file" name="attachment" />

Then add PHP code to upload action to upload file to local system:

<?php

$uploader = new \Sokil\Upload\Handler([
    'fieldName' => 'attachment',
]);
$uploader->moveLocal(__DIR__ . '/uploads/');

Also library supports Gaufrette filesistems. Read about Gaufrette at https://github.com/KnpLabs/Gaufrette. Read abount configuring Gaufrette filesystems in Symfony at https://github.com/KnpLabs/KnpGaufretteBundle.

To upload file into Gaufrette Filesystem:

<?php

$filesystem = new \Gaufrette\Filesystem(new \Gaufrette\Adapter\Local(
    __DIR__ . '/attachments/'
));

$uploader = new \Sokil\Upload\Handler([
    'fieldName' => 'attachment',
]);
$uploader->move($filesystem);

Upload transports

Stream upload

Nginx upload

Multipart Form Data Transport

Nginx configuration

During standard upload file is moved to php's temp dir, and then moved to target destination using move_uploaded_file. If this dirs on different physical drives, some time will be spend to move file physically between devices.

There is another reason when nginx + php-fpm stack used. During upload nginx stored file to its own temp dir. After passing control to php-fpm, nginx moves cached file to php's temp dir, and than php moves file to destination using move_uploaded_file. So file copied three times, and maybe on different physical devices.

This method moves file directly to configured drive, so in php code only rename of file required.

Using upload_module and upload_progress_module (nginx < 1.3.9)

This method is deprecated due to compilation errors of upload_module on nginx versions 1.3.9+.

Nginx must be compiled with this modules:

--add-module=/path/to/nginx-upload-module
--add-module=/path/to/nginx-upload-progress-module

Example of nginx configuration to handle upload and progress:

upload_progress upload 5m;

server
{
    location @php
    {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root/app.php;
        include /etc/nginx/fastcgi_params;
    }

    location /upload
    {
        upload_pass @php;
        upload_store %PATH_TO_STORAGE_DIRECTORY%;
        upload_pass_args on;
        upload_max_file_size 0;

        upload_set_form_field $upload_field_name.name "$upload_file_name";
        upload_set_form_field $upload_field_name.type "$upload_content_type";
        upload_set_form_field $upload_field_name.tmp_name "$upload_tmp_path";

        upload_aggregate_form_field $upload_field_name.size "$upload_file_size";

        track_uploads upload 5s;
    }

    location /progress
    {
        report_uploads upload;
    }

}

Using client_body_in_file_only directive

See more info at http://nginx.org/en/docs/http/ngx_http_core_module.html#client_body_in_file_only

Currently not supported

sokil/php-upload 适用场景与选型建议

sokil/php-upload 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 258 次下载、GitHub Stars 达 2, 最近一次更新时间为 2014 年 01 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 sokil/php-upload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sokil/php-upload 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-28