承接 locomotivemtl/charcoal-contrib-filepond 相关项目开发

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

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

locomotivemtl/charcoal-contrib-filepond

Composer 安装命令:

composer require locomotivemtl/charcoal-contrib-filepond

包简介

Charcoal filepond server adaptor

关键字:

README 文档

README

License Latest Stable Version Code Quality Coverage Status Build Status

A Charcoal service provider for FilePond.

FilePond is a JavaScript library that can upload anything you throw at it, optimizes images for faster uploads, and offers a great, accessible, silky smooth user experience.

This contrib act in fact as an upload server to go along with FilePond.

Table of Contents

Installation

The preferred (and only supported) method is with Composer:

$ composer require locomotivemtl/charcoal-contrib-filepond

Then add the module to your project's module list like so:

{
    "modules": {
        "charcoal/file-pond/file-pond": {}
    }
}

Dependencies

Required

  • PHP 5.6+: PHP 7 is recommended.
  • ext-fileinfo: "*",
  • league/flysystem ^1.0,
  • locomotivemtl/charcoal-app >= 0.7

Service Provider

Charcoal\FilePond\ServiceProvider\FilePondServiceProvider

The service provider is automatically instantiated by the module.

Services

  • FilePondService.php FilePondService can be invoked with a server config ident to bind it to a server when needed :

    $action = new RequestAction([
        'logger'          => $container['logger'],
        'filePondService' => $container['file-pond/service']($serverIdent),
    ]);
  • FilePondConfig.php

Configuration

The configuration for FilePond can be found here : FilePondConfig.php.

It uses the config file file-pond.json as default configset and can be overridden in your project's config.

getServer($ident) and getServers() can be called on the config to retrieve server configuration(s) : ServerConfig.php

The config defines a list of servers :

A server is a combination of an endpoint mapped with a filesystem and information regarding file paths.

Server options.

Option Description Default value
route The server endpoint url for the front-end app. Feeds the server option of FilePond.js /file-pond
filesystem_ident Which Filesystem to use. See charcoal-app. private
upload_path The definitive upload path root for files once the submission is completed. This path can be overridden in the submission action. The Helper FilePondAwareTrait will attempt to save the upload using the property's upload_path uploads/file-pond
transfer_dir The temporary file-pond folder root. Used while processing front-end file upload. Files from this directory will be transferred to there final location after the submission is completed. tmp/file-pond

Usage

Overrides the Module Config as needed by copying the file-pond.json structure in your project's config file as so:

{
    "contrib": {
        "file-pond": {
            "config": {
                "servers": {
                    "default": {
                        "route": "/file-pond",
                        "filesystem_ident": "private",
                        "upload_path": "uploads/file-pond",
                        "transfer_dir": "tmp/file-pond"
                    },
                    "s3": {
                        "route": "/file-pond/s3",
                        "filesystem_ident": "s3",
                        "upload_path": "uploads/file-pond",
                        "transfer_dir": "tmp/file-pond"
                    }
                }
            }
        }
    }
}

Set a route to give to the FilePond.js front-end framework. A slim route will automatically be created using the desired pattern. Once that is done, configure the front-end file-pond module using the correct FilePond documentation.

The key part of this process is that when the form is submitted, the server handles the transferring of previously uploaded files to their final paths. This allows to move uploads to folders that contains a user specific id and conceals the real path mapping of the server for security reasons.

You can use the FilePondAwareTrait on the action controller to handle filepond transfers. First set the required dependencies like that:

<?php

// From 'charcoal-contrib-filepond'
use Charcoal\FilePond\Service\Helper\FilePondAwareTrait;

/**
 * Create a new instructor.
 */
class SomeAction extends AbstractAction
{
    use FilePondAwareTrait;

    /**
     * Inject dependencies from a DI Container.
     *
     * @param Container $container A Pimple DI service container.
     * @return void
     */
    public function setDependencies(Container $container)
    {
        parent::setDependencies($container);

        $this->setFilePondService($container['file-pond/service']('private'));
    }
}

Then you can use the handleTransfer() method to facilitate the transfer upload process.

handleTransfer() for reference :

/**
 * Attempts to handle the transfer of uploads given the proper parameters.
 * If possible, it will try to :
 * - fetch the upload path from the property.
 * - fetch the filesystem based on the public access of the property.
 * - Pass it through the best processor depending on wether their were ids passed or not.
 *
 * @param string|array|null             $ids        The uploaded files ids. Let to null to force $_FILES and $_POST.
 * @param string|PropertyInterface|null $property   The property ident or a property.
 * @param ModelInterface|string|null    $context    The context object as model or class ident.
 * @param string|null                   $pathSuffix Path suffix.
 * @return array
 */
protected function handleTransfer(
    $ids = null,
    $property = null,
    $context = null,
    $pathSuffix = null
)

Example of usage :

/** Transfer uploaded files */
$files = $this->handleTransfer(
    $submissionData['someProp'],
    'some_prop',
    $someModel,
    $someModel->property('id')->autoGenerate()
);

Development

To install the development environment:

$ composer install

To run the scripts (phplint, phpcs, and phpunit):

$ composer test

API Documentation

Development Dependencies

  • [php-coveralls/php-coveralls][phpcov]
  • [phpunit/phpunit][phpunit]
  • [squizlabs/php_codesniffer][phpcs]

Coding Style

The charcoal-contrib-filepond module follows the Charcoal coding-style:

Coding style validation / enforcement can be performed with composer phpcs. An auto-fixer is also available with composer phpcbf.

Credits

License

Charcoal is licensed under the MIT license. See LICENSE for details.

locomotivemtl/charcoal-contrib-filepond 适用场景与选型建议

locomotivemtl/charcoal-contrib-filepond 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 582 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「charcoal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 locomotivemtl/charcoal-contrib-filepond 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 13
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-28