PHPackages                             bushbaby/gaufrette - 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. bushbaby/gaufrette

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

bushbaby/gaufrette
==================

A Zend Framework 2 module that provides easy configuration and access to the Gaufrette filesystem abstraction layer.

211PHP

Since Nov 8Pushed 9y ago2 watchersCompare

[ Source](https://github.com/basz/BsbGaufretteModule)[ Packagist](https://packagist.org/packages/bushbaby/gaufrette)[ RSS](/packages/bushbaby-gaufrette/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

BsbGaufrette
============

[](#bsbgaufrette)

BsbGaufrette is a Zendframework 2 module that provides easy configuration and access to the [Gaufrette Filesystem](https://github.com/knpLabs/Gaufrette "Gaufrette").

Main Features
-------------

[](#main-features)

1. Exposing Gaufrette adapters via the ServiceManager via simple configuration. This feature is mostly done and not subject.
2. Ability to easily work with entity object that have associated files... This feature is still considered proof of concept. The *ultimate* goal is to get this to work with Doctrine entities.

*The Gaufrette api itself isn't stable yet and as such subject to change.*

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

[](#installation)

### with Composer

[](#with-composer)

modify your ./composer.json so it includes

```
"require": {
    "bushbaby/gaufrette" : "dev-master"
}

```

then execute in your project root, which will install the module as well as the Gaufrette library.

```
composer.phar update

```

Activation
----------

[](#activation)

Finally modify the "modules' key in ./config/application.config.php so it contains "BsbGaufrette" to activate BsbGaufrette within your project.

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

[](#configuration)

Copy a provided configuration template to the autload directory to get started quickly.

```
cp ./vendor/bushbaby/gaufrette/config/bsbgaufrette.global.dist.php \
   ./config/autoload/bsbgaufrette.global.php

```

Usage
-----

[](#usage)

### the Gaufrette Manager

[](#the-gaufrette-manager)

At this point you are able to get to the Gaufrette Manager via the service manager.

```
$sm = $this->getServiceManager();
$gm = $sm->get('bsbGaufretteManager'); // aliased as 'bsbFS'

```

This manager contains a plugin loader that knows how to instantiate all (currently only local and safelocal) of the adapters provided by the Gaufrette library via factories. Do that via the get($name) method.

```
$fs = $gm->get('my_local_save_place');

```

When the name hasn't been configured an exception is thrown. Use the has($name) method when you need test for its existance.

```
if ($gm->has('my_local_save_place')) {
    $fs = $gm->get('my_local_save_place');
}

```

Any object returned is guaranteed to extend \\Gaufrette\\Adapter\\Base and as such you can now do:

```
$fs->write('my-book.txt', 'once upon a time');

```

### Configuring Gaufrette file systems

[](#configuring-gaufrette-file-systems)

To be able to retrieve Gaufrette adapters via the Gaufrette manager you need to define them under a 'key' in the module configuration. Configuration pretty much explains itself.

```
