Skip to content

Simple Factory for the League\Flysystem filesystem abstraction library

License

Notifications You must be signed in to change notification settings

Westwing-Home-and-Living/flysystem-factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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":  "git@github.com: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:

About

Simple Factory for the League\Flysystem filesystem abstraction library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages