PHPackages                             locomotivemtl/charcoal-contrib-filepond - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. locomotivemtl/charcoal-contrib-filepond

ActiveLibrary[File &amp; Storage](/categories/file-storage)

locomotivemtl/charcoal-contrib-filepond
=======================================

Charcoal filepond server adaptor

0.3.1.1(5y ago)05782[2 PRs](https://github.com/locomotivemtl/charcoal-contrib-filepond/pulls)MITPHPPHP &gt;=5.6.0 || &gt;=7.0CI failing

Since Jul 3Pushed 5mo ago13 watchersCompare

[ Source](https://github.com/locomotivemtl/charcoal-contrib-filepond)[ Packagist](https://packagist.org/packages/locomotivemtl/charcoal-contrib-filepond)[ Docs](https://locomotivemtl.github.io/charcoal-contrib-filepond/)[ RSS](/packages/locomotivemtl-charcoal-contrib-filepond/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (9)Used By (0)

Charcoal FilePond
=================

[](#charcoal-filepond)

[![License](https://camo.githubusercontent.com/813011a18f6b49328163adde063fec4c0cf8b4abe94570974ba6d0dd5f0572e8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d66696c65706f6e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-filepond)[![Latest Stable Version](https://camo.githubusercontent.com/3f13a4acb4185ec6fe9d5e42dc301fbef9e8cda8fb1d302c6e6054aa2a8eaf11/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d66696c65706f6e642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/locomotivemtl/charcoal-contrib-filepond)[![Code Quality](https://camo.githubusercontent.com/09e40b834f4cc2020b25c1cd66f6fbb8afca330df0168461ccbf56815731a03a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d66696c65706f6e642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/locomotivemtl/charcoal-contrib-filepond/)[![Coverage Status](https://camo.githubusercontent.com/f5956c52e4c0423710c674fb4a746873ae04b532b4d1b4c730e0b0a96f5c2c9c/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d66696c65706f6e642e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/r/locomotivemtl/charcoal-contrib-filepond)[![Build Status](https://camo.githubusercontent.com/0ad899fa14aca68d05e1d12716b107250d6077cc6eb589f2e28e1580daaee957/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c6f636f6d6f746976656d746c2f63686172636f616c2d636f6e747269622d66696c65706f6e642e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/locomotivemtl/charcoal-contrib-filepond)

A [Charcoal](https://packagist.org/packages/locomotivemtl/charcoal-app) service provider for FilePond.

[FilePond](https://pqina.nl/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
-----------------

[](#table-of-contents)

- [Installation](#installation)
    - [Dependencies](#dependencies)
- [Service Provider](#service-provider)
    - [Parameters](#parameters)
    - [Services](#services)
- [Configuration](#configuration)
- [Usage](#usage)
- [Development](#development)
    - [API Documentation](#api-documentation)
    - [Development Dependencies](#development-dependencies)
    - [Coding Style](#coding-style)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#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

[](#dependencies)

#### Required

[](#required)

- [**PHP 5.6+**](https://php.net): *PHP 7* is recommended.
- ext-fileinfo: "\*",
- league/flysystem ^1.0,
- locomotivemtl/charcoal-app &gt;= 0.7

Service Provider
----------------

[](#service-provider)

Charcoal\\FilePond\\ServiceProvider\\FilePondServiceProvider

The service provider is automatically instantiated by the module.

### Services

[](#services)

- [FilePondService.php](src/Charcoal/FilePond/Service/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](src/Charcoal/FilePond/FilePondConfig.php)

Configuration
-------------

[](#configuration)

The configuration for FilePond can be found here : [FilePondConfig.php](src/Charcoal/FilePond/FilePondConfig.php).

It uses the config file [file-pond.json](config/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](src/Charcoal/FilePond/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.

[](#server-options)

OptionDescriptionDefault valuerouteThe server endpoint url for the front-end app. Feeds the **server** option of FilePond.js/file-pondfilesystem\_identWhich **Filesystem** to use. See [charcoal-app](https://github.com/locomotivemtl/charcoal-app/blob/e2e8af2eb6001da6d75ea100d191f73365f1ff77/src/Charcoal/App/ServiceProvider/FilesystemServiceProvider.php#L45).privateupload\_pathThe definitive upload path root for files once the submission is completed. This path can be overridden in the submission action. The Helper [FilePondAwareTrait](src/Charcoal/FilePond/Service/Helper/FilePondAwareTrait) will attempt to save the upload using the property's **upload\_path**uploads/file-pondtransfer\_dirThe 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-pondUsage
-----

[](#usage)

Overrides the Module Config as needed by copying the [file-pond.json](config/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.

- [FilePond vanilla installation](https://pqina.nl/filepond/docs/patterns/installation/)
- [FilePond vanilla documentation](https://pqina.nl/filepond/docs/patterns/api/filepond-object/#creating-a-filepond-instance)
- [FilePond available frameworks](https://pqina.nl/filepond/docs/patterns/frameworks/introduction/)

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](src/Charcoal/FilePond/Service/Helper/FilePondAwareTrait) on the action controller to handle filepond transfers. First set the required dependencies like that:

```
