Skip to content

Latest commit

 

History

History
106 lines (76 loc) · 2.31 KB

Readme.md

File metadata and controls

106 lines (76 loc) · 2.31 KB

Filesystem

Author Software License Build Status

Description

Simple Factory for the League\Flysystem filesystem abstraction library.

Goals

  • Provide a simpler way of creating the different adapters based on a configuration file.
  • Add validations to the config file.
  • Add Validation to the different adapters.

Installation

Add the following lines to your composer.json:

{
    "require": {
        "Westwing-Home-and-Living/flysystem-factory": "v0.2"
    },
    "repositories": [
        {
            "type": "vcs",
            "url":  "[email protected]:Westwing-Home-and-Living/flysystem-factory.git"
        }
    ]
}

Note: Modify the version accordingly

Integrations

Want to get started quickly? Check out the Recipes folder!

  • Zend Framework 1

Adapters

Adapters currently implemented:

  • Local
  • Ftp
  • AwsS3

Examples

Providing the configuration to the Factory as an array

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Westwing\Filesystem\Factory;
use Symfony\Component\Yaml\Yaml;

$config            = Yaml::parse(file_get_contents(__DIR__ . 'filesystem.yml'));
$fileSystemFactory = new Factory();

$fileSystemFactory->setConfig($config);

$fileSystem = $fileSystemFactory->get('localFS');

print_r($fileSystem->listContents());

Providing a Yaml config file to the Factory

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Westwing\Filesystem\Factory;

$fileSystemFactory = new Factory();
$fileSystemFactory->setConfigFile(__DIR__ . 'filesystem.yml');

$fileSystem = $fileSystemFactory->get('localFS');

print_r($fileSystem->listContents());

For both examples, the Yaml config file used was:

Filesystem:
  adapter:
    localFS:
      type: "Local"
      root: "."
    sharedFS:
      type: "AwsS3"
      key:
      secret:
      region:
      bucket:
      prefix:
      options:
        Body:
        ContentType:
        ContentLength: