PHPackages                             barberry/barberry - 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. barberry/barberry

ActiveLibrary

barberry/barberry
=================

4.1.0(1y ago)3161.9k↓38.2%7[5 issues](https://github.com/Magomogo/Barberry/issues)MITPHPPHP &gt;=7.4CI passing

Since Nov 7Pushed 11mo ago6 watchersCompare

[ Source](https://github.com/Magomogo/Barberry)[ Packagist](https://packagist.org/packages/barberry/barberry)[ RSS](/packages/barberry-barberry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (18)Used By (0)

[![Build Status](https://camo.githubusercontent.com/50b84b3897159e0260f1133a607e95e7145d563f0798e5fef8372a1400d2c56d/68747470733a2f2f7472617669732d63692e6f72672f4d61676f6d6f676f2f42617262657272792e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/Magomogo/Barberry)

The problem
===========

[](#the-problem)

Every web project have different binary data to host and handle: images, PDFs, etc. In most cases those files should be converted in different ways:

- images: resize and format
- PDF to image
- Open office templates to MS Office documents and PDFs

Solution
========

[](#solution)

This application can host a binary/text data (**Documents**) of a particular content type and convert it in requested way.

It intended to be deployed at separate hostname as bin.*project-hostname*. Also it is recommended to use cookieless domain for read-only serving of public content.

Installation
============

[](#installation)

```
composer install
./phpunit

```

Usage
=====

[](#usage)

We desided to use REST interface. Here are the commands.

POST
----

[](#post)

Submitting data to the service.

```
Url: /
Data: Document and (optionally) variables to parse if Document is a template
Return: {id : "_auto_generated_id_string_", contentType: "_content_type_",
    ext: "_standart_file_extension_", length: _file_size_, filename: "_original_file_name_"}

```

GET
---

[](#get)

Getting a **document**.

```
Url: /_id_string_._ext_
Data: no
Return: Document

```

**Example**: /12wkr234ser349.pdf - get document "12wkr234ser349" as PDF

Getting a **document** related to some restricted group

```
Url: /_auth_group_3_letters_/_id_string_._ext_
Data: no
Return: Document

```

**Example**: /adm/6b12YX.pdf - get document "12wkr234ser349" as PDF

Restriction of /adm/\* URIs should be done externally. See section **Authorization** below.

DELETE
------

[](#delete)

Deleting a **document**.

```
Url: /_id_string_
Data: no
Return: {}

```

Deployment
==========

[](#deployment)

See  as a reference. Target application should depends from barberry/barberry and necessary converter plugins. Dependencies are handled with Composer.

Plugins
-------

[](#plugins)

-  - images conversion
-  - PDF to text, PDF to image
-  - make web sites screen shots as image or PDF with webkit engine
-  - XSL, DOC, PDF other spreadsheet, templates and documents
-  - converting video, taking frameshots

Authorization
=============

[](#authorization)

Authorization should be done externally.

Example: Restrict all methods except GET with apache web server
---------------------------------------------------------------

[](#example-restrict-all-methods-except-get-with-apache-web-server)

```

    AuthName "Restricted method"
    AuthType Basic
    AuthBasicProvider file
    AuthUserFile %PUT_THE_PATH_HERE%/passwords

        Require valid-user

    DirectoryIndex index.php

```

Magic
=====

[](#magic)

```
magic.mime.mgc version 8 (file version 5.09) is compatible only with php >=5.3.11
magic.mime.mgc version 7 (file version 5.04) is compatible with php
