PHPackages                             fei/filer-client - 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. fei/filer-client

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

fei/filer-client
================

Flash applicative Filer - client component

v3.0.1(7y ago)06.5k[3 PRs](https://github.com/flash-global/filer-client/pulls)1proprietaryPHP

Since Jan 25Pushed 2y ago23 watchersCompare

[ Source](https://github.com/flash-global/filer-client)[ Packagist](https://packagist.org/packages/fei/filer-client)[ RSS](/packages/fei-filer-client/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (3)Versions (30)Used By (1)

Filer Client
============

[](#filer-client)

[![GitHub license](https://camo.githubusercontent.com/b897a1b6ef6854415596dd0034d4d1cb5a66fdfb3c0b1ab87d7dc0a316657040/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f666c6173682d676c6f62616c2f66696c65722d636c69656e742e737667)](https://github.com/flash-global/filer-client)[![continuousphp](https://camo.githubusercontent.com/cae6f0b46edcd6edd717f988ce99355d09d70a215afb6d95e3906db5c3c62b3f/68747470733a2f2f696d672e736869656c64732e696f2f636f6e74696e756f75737068702f6769742d6875622f666c6173682d676c6f62616c2f66696c65722d636c69656e742e737667)](https://camo.githubusercontent.com/cae6f0b46edcd6edd717f988ce99355d09d70a215afb6d95e3906db5c3c62b3f/68747470733a2f2f696d672e736869656c64732e696f2f636f6e74696e756f75737068702f6769742d6875622f666c6173682d676c6f62616c2f66696c65722d636c69656e742e737667)[![Build Status](https://camo.githubusercontent.com/f084cd3c2b65a8390ad747c2bab9677daa28c89c250bcb54ee11abbe1c7258af/68747470733a2f2f7472617669732d63692e6f72672f666c6173682d676c6f62616c2f66696c65722d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/flash-global/filer-client)[![GitHub issues](https://camo.githubusercontent.com/6defaaa42d1c575ee1876db0934ce7d3c91bbd36009cc781e62e4552222fe218/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f666c6173682d676c6f62616c2f66696c65722d636c69656e742e737667)](https://github.com/flash-global/filer-client/issues)

This is the client you should use for consuming the Filer service.

The client can use two kinds of transports to send requests:

- Asynchronous transport implemented by `BeanstalkProxyTransport`
- Synchronous transport implemented by `BasicTransport`

`BeanstalkProxyTransport` delegate the API consumption to workers by sending file properties to a Beanstalkd queue.

`BasicTransport` use the *classic* HTTP layer to send files.

If asynchronous transport is set, it will act as default transport. Synchronous transport will be a fallback in case when asynchronous transport fails.

All examples in this document will use `BeanstalkProxyTransport` and `BasicTransport`.

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

[](#installation)

Filer Client needs **PHP 5.5** or higher.

Add this requirement to your `composer.json`: `"fei/filer-client": : "^1.0"`

Or execute `composer.phar require fei/filer-client` in your terminal.

If you want use the asynchronous functionality of the Filer client (and we know you want), you need an instance of [Beanstalkd](http://kr.github.io/beanstalkd/) which running properly and an instance of `api-client-worker.php` which will consume the Beanstalk's pipe and forward messages payload to the Filer API:

```
Filer Client -> Beanstalkd -> api-client-worker.php -> Filer API server

```

### Beanstalkd configuration

[](#beanstalkd-configuration)

Running Beanstalkd is very simple. However, you must pay attention to the `z` option which set the maximum job (or message) size in bytes. So, if you want transfer 100 Mo files to Filer API, you should consider at least a value of 16O Mo for the `z` parameter.

```
beanstalkd -z 167772160

```

### Run `api-client-worker.php`

[](#run-api-client-workerphp)

You could see below an example of running `api-client-worker.php`:

```
php /path/to/filer-client/vendor/bin/api-client-worker.php --host 127.0.0.1 --port 11300 --delay 3

```

OptionsShortcutDescriptionDefaulthost`-h`The host of Beanstalkd instance`localhost`port`-p`The port which Beanstalkd instance listening`11300`delay`-d`The delay between two treatment of the worker3 secondsverbose`-v`Print verbose information-You can control the `api-client-worker.php` process by using [Supervisor](http://supervisord.org/index.html).

Entities and classes
--------------------

[](#entities-and-classes)

### File entity

[](#file-entity)

In addition to traditional ID and CreatedAt fields, File Entity has \**six* important properties:

PropertiesTypeid`integer`createdAt`datetime`filename`string`uuid`string`revision`integer`category`integer`contentType`string`data`string`file`string`contexts`ArrayColleciton`- `$uuid` (Universal Unique Identifier) is a **unique id** corresponding to a file. Its format is based on **36 characters** as defined in `RFC4122` prefixed by a **backend id** and separated by a `:`. Example: `bck1:f6461366-a414-4b98-a76d-d7b190252e74`
- `filename` is a string indicating the file's filename.
- `revision` is an integer indicating the file's current revision.
- `category` is an integer defining in which database the file will be stored in.
- `contentType` defines the content type of the `File` object.
- `data` contains the file's content.
- `file` is an `SplFileObject` instance. (see  for more details)
- `contexts` is an `ArrayCollection` instance where each element is a Context entity

Basic usage
-----------

[](#basic-usage)

In order to consume `File` method, you have to define a new `Filer` instance and set transport type (Async and Sync):

```
