Download the PHP package / without Composer

On this page you can find all versions of the php package /. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
/
Rate from 1 - 5
Rated 5.00 based on 2 reviews

Informations about the package

Filer Client

GitHub license continuousphp Build Status GitHub issues

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

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

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

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 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:

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.

Run api-client-worker.php

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

Options Shortcut Description Default
host -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 worker 3 seconds
verbose -v Print verbose information -

You can control the api-client-worker.php process by using Supervisor.

Entities and classes

File entity

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

Properties Type
id integer
createdAt datetime
filename string
uuid string
revision integer
category integer
contentType string
data string
file string
contexts ArrayColleciton

Basic usage

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

Filer client instance will first attempt to transfer the messages with Beanstalkd, if the process fail then the client will try to send File payload directly to the right API endpoint.

There are several methods in Filer class, all listed in the following table:

Method Parameters Return
upload File $file, $flags = null null or string
uploadByChunks File $file, $flags = null null or string
retrieve string $uuid null or File
delete string $uuid null
truncate string $uuid, int $keep = 0 null
serve string $uuid string
save string $uuid, string $path string as null
embed string $path null or File

$uuid (Universal Unique Identifier) is a unique id corresponding to a file. (see File entity part)

Client option

Only one option is available which can be passed to the constructor or Filer::setOptions(array $options) methods:

Option Description Type Possible Values Default
OPTION_BASEURL This is the server to which send the requests. string Any URL, including protocol but excluding path -
OPTION_HEADER_AUTHORIZATION Api Key for authentification string Any string value ''

Note: All the examples below are also available in examples directory.

Search the files

You can search the files directly from the client with Filer::search($builder)

You can create your searches using the SearchBuilder to make the search easier to use.

As you can see mutiple methods are available like filename and multiple operators methods too like :

Note that you can search on multiple categories by adding multiple categories filter :

Note that you can filter on contexts. By default if you have multiple filter for the contexts, an "AND" condition will be processed. You can choose to do an "OR" condition by making the following filter :

You can also search a file by giving an uuid. If you do this king of search you don't need to filter by categories but you still can if you want.

Here is an example on how to search a file with it's uuid :

Upload a new file

You can upload a file instance with Filer::upload($file, $flags):

The function will return null or a string describing the new file path.

Example

An other way to create a File instance is to use the static method Filer::embed($path) which allows you to create a file instance using a local file path:

Retrieve a file

You can retrieve a file instance with Filer::retrieve($uuid). The only necessary parameter is a valid file uuid.

This method returns a File instance or null if the file was not found.

Example

Delete a file

You can delete a file with Filer::delete($uuid). The only necessary parameter is a valid file uuid.

Example

Truncate a file

The Filer::truncate($uuid, $keep = 0) method allows you to remove every revisions of a file, except a determined number of revisions.

Example

Save

Filer::save($uuid, $path, $as = null) method is a way to retrieve and save a local copy of a remote File.

Example

Serve a file

With the method Filer::serve($uuid, $flag = Filer::FORCE_DOWNLOAD) you can serve a file to user agents and force the download.

If you don't want to download the file and show it, you can call the method like this: Filer::serve($uuid, Filer::FORCE_INLINE)

Example

Upload large files by chunk

From the version 1.1.0 of this client it is possible tu upload large file by chunk. In order to do this, ypu have to use the Filer::uploadByChunk(File $file, callable $fulfilled = null, callable $rejected = null) method.

Example

$fulfilled callback will be executed each time a chunk is transmitted successfully. Otherwise $rejected callback will be executed each time a chunk is not transmitted successfully.

By default, $rejected is equal to:

You could set the chunk size and the Upload concurrency with respectively the options OPTION_CHUNK_SIZE and OPTION_CHUNK_UPLOAD_CONCURRENCY.


All versions of with dependencies

PHP Build Version
Package Version
Requires fei/api-client Version ^1.1
fei/filer-common Version ~1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package / contains the following files

Loading the files please wait ....