/**
  * Creates the Filesystem based on the application.ini config and
  * sets it in the Zend_Registry with the "sharedFS" key.
  *
  * @author Josemi Liébana <*****@*****.**>
  *
  * @throws Zend_Exception
  *
  * @throws \League\Flysystem\Exception
  */
 public function init()
 {
     /** @var Zend_Config $config */
     $config = Zend_Registry::get('config');
     if (!$config instanceof Zend_Config) {
         throw new Exception(Factory::ERROR_CONFIG_AND_CONFIG_FILE_NOT_SET);
     }
     try {
         $config = $config->resources->Filesystem;
     } catch (Exception $e) {
         throw new Exception(Factory::ERROR_CONFIG_AND_CONFIG_FILE_NOT_SET);
     }
     $adapterIndex = Config::INDEX_ADAPTER;
     $defaultAdapterIndex = Config::INDEX_DEFAULT_ADAPTER;
     /** @var array $config */
     $config = $config->toArray();
     if (empty($config[$adapterIndex]) || !is_array($config[$adapterIndex])) {
         throw new Exception(Factory::ERROR_BAD_CONFIG);
     }
     $defaultAdapter = !empty($config[$defaultAdapterIndex]) ? $config[$defaultAdapterIndex] : null;
     $fileSystemFactory = new Factory();
     $adaptersConfig = $config[$adapterIndex];
     foreach ($adaptersConfig as $adapterName => $config) {
         $filesystemConfig = array(Config::INDEX_FILESYSTEM => array($adapterIndex => array($adapterName => $config)));
         $fileSystemFactory->setConfig($filesystemConfig);
         $filesystem = $fileSystemFactory->get($adapterName);
         Zend_Registry::set($adapterName, $filesystem);
         if ($adapterName === $defaultAdapter) {
             Zend_Registry::set($defaultAdapterIndex, $filesystem);
         }
     }
 }
 /**
  * Test that the factory can create a League\\filesystem object with the specifed Adapter
  *
  * @author Josemi Liébana <*****@*****.**>
  *
  * @throws Exception
  */
 public function testFactoryWithConfigAndSingleLocalAdapter()
 {
     $filesystemFactory = new Filesystem\Factory();
     $filesystemFactory->setConfig($this->getValidSingleAdapterConfig());
     $filesystem = $filesystemFactory->get($this->adapterName);
     $this->assertInstanceOf('League\\Flysystem\\AdapterInterface', $filesystem->getAdapter());
     $this->assertInstanceOf('League\\Flysystem\\Filesystem', $filesystem);
 }
<?php

// Providing a Yaml config file to the Factory
require_once __DIR__ . '/../vendor/autoload.php';
use Westwing\Filesystem\Factory;
$fileSystemFactory = new Factory();
$fileSystemFactory->setConfigFile(__DIR__ . '/filesystem.yml');
$fileSystem = $fileSystemFactory->get('ftpFS');
print_r($fileSystem->listContents());
<?php

// Providing the configuration to the Factory as an array
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());