Git Product home page Git Product logo

gaufrette's Introduction

Gaufrette

Gaufrette is a PHP5 library that provides a filesystem abstraction layer.

This project does not have any stable release yet but we do not want to break BC now.

Build Status Join the chat at https://gitter.im/KnpLabs/Gaufrette Stories in Ready

Symfony integration is available here: KnpLabs/KnpGaufretteBundle.

Documentation is available here.

Why use Gaufrette?

Imagine you have to manage a lot of medias in a PHP project. Lets see how to take this situation in your advantage using Gaufrette.

The filesystem abstraction layer permits you to develop your application without the need to know were all those medias will be stored and how.

Another advantage of this is the possibility to update the files location without any impact on the code apart from the definition of your filesystem. In example, if your project grows up very fast and if your server reaches its limits, you can easily move your medias in an Amazon S3 server or any other solution.

Try it!

php composer.phar require knplabs/gaufrette:~0.2 # Stable version
php composer.phar require knplabs/gaufrette:0.4.*@dev # Development version

Following an example with the local filesystem adapter. To setup other adapters, look up their respective documentation.

<?php

use Gaufrette\Filesystem;
use Gaufrette\Adapter\Local as LocalAdapter;

// First, you need a filesystem adapter
$adapter = new LocalAdapter('/var/media');
$filesystem = new Filesystem($adapter);

// Then, you can access your filesystem directly
var_dump($filesystem->read('myFile')); // bool(false)
$filesystem->write('myFile', 'Hello world!');

// Or use File objects
$file = $filesystem->get('myFile');
// Will print something like: "myFile (modified 17/01/2016 18:40:36): Hello world!"
echo sprintf('%s (modified %s): %s', $file->getKey(), date('d/m/Y, H:i:s', $file->getMtime()), $file->getContent());

Running the Tests

The tests use phpspec2 and PHPUnit.

Setup the vendor libraries

As some filesystem adapters use vendor libraries, you should install the vendors:

$ cd gaufrette
$ php composer.phar install
$ sh bin/configure_test_env.sh

It will avoid skip a lot of tests.

Launch the Test Suite

In the Gaufrette root directory:

To check if classes specification pass:

$ php bin/phpspec run

To check basic functionality of the adapters (adapters should be configured you will see many skipped tests):

$ bin/phpunit

Is it green?

gaufrette's People

Contributors

aderuwe avatar afitzke avatar akovalyov avatar anacicconi avatar andrewtch avatar baachi avatar benjamindulau avatar cdfre avatar damienalexandre avatar ddeboer avatar docteurklein avatar estahn avatar gesthispania avatar hason avatar havvg avatar herzult avatar l3l0 avatar markuspoerschke avatar maxakawizard avatar mtarvainen avatar mtdowling avatar nek- avatar pawski avatar qpleple avatar richtermeister avatar schmittjoh avatar stloyd avatar stof avatar woodsae avatar wysow avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.