PHPackages                             ashleydawson/doctrine-flysystem-bundle - 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. ashleydawson/doctrine-flysystem-bundle

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

ashleydawson/doctrine-flysystem-bundle
======================================

Add a flysystem storage behaviour (trait) to Doctrine entities in Symfony 2

0.8.7(9y ago)57.9k2MITPHPPHP &gt;=5.4

Since Apr 23Pushed 7y ago1 watchersCompare

[ Source](https://github.com/AshleyDawson/DoctrineFlysystemBundle)[ Packagist](https://packagist.org/packages/ashleydawson/doctrine-flysystem-bundle)[ RSS](/packages/ashleydawson-doctrine-flysystem-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (10)Used By (0)

Doctrine Flysystem Bundle
=========================

[](#doctrine-flysystem-bundle)

[![Build Status](https://camo.githubusercontent.com/fae98d332667e9a64d906a5836b9e62bb03ed0512bd58377698fdb079b70e894/68747470733a2f2f7472617669732d63692e6f72672f4173686c6579446177736f6e2f446f637472696e65466c7973797374656d42756e646c652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/AshleyDawson/DoctrineFlysystemBundle)

[![knpbundles.com](https://camo.githubusercontent.com/2581a9822b718bf4465eef8950923fe95da093d2d01887e63e2056c0d8f4b679/687474703a2f2f6b6e7062756e646c65732e636f6d2f4173686c6579446177736f6e2f446f637472696e65466c7973797374656d42756e646c652f62616467652d73686f7274)](http://knpbundles.com/AshleyDawson/DoctrineFlysystemBundle)

Add a flysystem storage behaviour to Doctrine entities in Symfony 2

Requirements
------------

[](#requirements)

```
 >= PHP 5.4
 >= Symfony Framework 2.3

```

Doctrine Support
----------------

[](#doctrine-support)

- Support for Doctrine ORM - Complete
- Support for Doctrine ODM - Incomplete

Introduction
------------

[](#introduction)

I built this bundle to extend [Flysystem](https://github.com/thephpleague/flysystem) filesystem abstraction. In fact, this library extends the [FlysystemBundle](https://github.com/1up-lab/OneupFlysystemBundle) for Symfony 2.

This bundle implements an "uploaded file" handler on [Doctrine](http://www.doctrine-project.org/) entities, allowing Flysystem to store the file as a part of the Doctrine entity lifecycle.

The first class citizen on the bundle is a **trait** that is applied to any Doctrine entity to give the Flysystem storage handler the ability to persist file details along with the entity.

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

[](#installation)

You can install the Doctrine Flysystem Bundle via Composer. To do that, simply require the package in your composer.json file like so:

```
{
    "require": {
        "ashleydawson/doctrine-flysystem-bundle": "0.8.*"
    }
}
```

Run composer update to install the package. Then you'll need to register the bundle in your `app/AppKernel.php`. The first of these examples uses the MultiBundle library to register the bundle and it's dependencies. For more information see the [MultiBundle docs](https://github.com/AshleyDawson/MultiBundle).

```
// app/AppKernel.php

$bundles = array(
    // ...,
);

// Do this after the production bundles are set
\AshleyDawson\DoctrineFlysystemBundle\AshleyDawsonDoctrineFlysystemBundle::registerInto($bundles);

// ...
```

Or you could do this the classic way:

```
// app/AppKernel.php

// ...

$bundles = array(
    // ...
    new Oneup\FlysystemBundle\OneupFlysystemBundle(), // Doctrine Flysystem Bundle depends on this
    new AshleyDawson\DoctrineFlysystemBundle\AshleyDawsonDoctrineFlysystemBundle(),
);

// ...
```

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

[](#configuration)

Next, you'll need to configure at least one filesystem to store your files in. I'll lay out an example below, however, a better example of this can be found in the [FlysystemBundle documentation](https://github.com/1up-lab/OneupFlysystemBundle/blob/master/Resources/doc/filesystem_create.md#use-the-mount-manager).

```
# app/config/config.yml
oneup_flysystem:
    adapters:
        my_adapter:
            local:
                directory: %kernel.root_dir%/cache

    filesystems:
        my_filesystem:
            adapter: my_adapter
            mount: my_filesystem_mount_name
```

**Note:** The line `mount: my_filesystem_mount_name` is important as this bundle references filesystems using their mount prefix as defined here

Usage
-----

[](#usage)

In order to use this bundle, you must apply the given trait to the entities you'd like to have store an uploaded file.

```
