1. Go to this page and download the library: Download middlewares/filesystem library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Ftp;
$filesystem = new Filesystem(new Ftp([
'host' => 'ftp.example.com',
'username' => 'username',
'password' => 'password',
'port' => 21,
'root' => '/path/to/root',
'passive' => true,
'ssl' => true,
'timeout' => 30,
]));
Dispatcher::run([
new Middlewares\Reader($filesystem)
]);
$responseFactory = new MyOwnResponseFactory();
$streamFactory = new MyOwnStreamFactory();
$reader = new Middlewares\Reader($filesystem, $responseFactory, $streamFactory);
$cache = new Flysystem(new Local(__DIR__.'/path/to/files'));
Dispatcher::run([
(new Middlewares\Reader($cache)) //read and returns the cached response...
->continueOnError(), //...but continue if the file does not exists
new Middlewares\Writer($cache), //save the response in the cache
new Middlewares\AuraRouter($route), //create a response using, for example, Aura.Router
]);
$filesystem = new Flysystem(new Local(__DIR__.'/storage'));
Dispatcher::run([
new Middlewares\Writer($filesystem)
]);
$streamFactory = new MyOwnStreamFactory();
$reader = new Middlewares\Writer($filesystem, $streamFactory);