2017 © Pedro Peláez
 

library cabinet

A filestore abstraction for PHP

image

99designs/cabinet

A filestore abstraction for PHP

  • Monday, August 26, 2013
  • by harto
  • Repository
  • 43 Watchers
  • 0 Stars
  • 29,956 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Cabinet is a filestore abstraction written in PHP. Filestores map string keys to files., (*1)

At the core of Cabinet is the FileStore interface, which defines most of the operations you'd find in a normal filesystem (read, write, delete, etc.). By programming to this interface, your application code remains unaware of the underlying filestore implementation., (*2)

Abstracting the filestore lets you swap one implementation for another without requiring changes to your application code. For example, you might use S3 in production, a local filesystem in dev, and an array-backed implementation in your unit tests., (*3)

Filestore implementations

Cabinet comes with a number of filestore implementations:, (*4)

  • FilesystemFileStore stores files in your local filesystem.
  • ArrayFileStore stores files in a PHP array.
  • NullFileStore is a black hole like /dev/null.

There are two additional wrapper implementations:, (*5)

  • ReadOnlyFileStore delegates read and write operations to two separate filestores.
  • MountPointFileStore provides a way to compose multiple filestores into a virtual filesystem.

To provide a custom implementation, write a class that implements Cabinet\FileStore., (*6)

Example usage

You'd typically defer construction of a filestore to a factory constructor:, (*7)

class FileStoreFactory
{
    public static function create() {
        // This might return an implementation based on your app config
        return new \Cabinet\FilesystemFileStore('/tmp/myfiles');
    }
}

Then your application code uses the filestore like so:, (*8)

$store = FileStoreFactory::create();
$file = $store->newFile('/foo/bar');
$store->setFileContents($file, 'some data');
$store->close($file);

This writes the given data to /tmp/myfiles/foo/bar., (*9)

The Versions

26/08 2013

dev-master

9999999-dev

A filestore abstraction for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

26/08 2013

1.0.0

1.0.0.0

A filestore abstraction for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

26/08 2013

dev-allow_optional_args

dev-allow_optional_args

A filestore abstraction for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires