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\Ftp\FtpAdapter;
use League\Flysystem\Ftp\FtpConnectionOptions;
$adapter = new League\Flysystem\Ftp\FtpAdapter(
FtpConnectionOptions::fromArray([
'host' => 'hostname',
'root' => '/root/path/',
'username' => 'username',
'password' => 'password',
'port' => 21,
'ssl' => false,
'timeout' => 90,
'utf8' => false,
'passive' => true,
'transferMode' => FTP_BINARY,
'systemType' => null, // 'windows' or 'unix'
'ignorePassiveAddress' => null, // true or false
'timestampsOnUnixListingsEnabled' => false, // true or false
'recurseManually' => true // true
])
);
// The FilesystemOperator
$filesystem = new Filesystem($adapter);
Dispatcher::run([
new Middlewares\Reader($filesystem)
]);
$responseFactory = new MyOwnResponseFactory();
$streamFactory = new MyOwnStreamFactory();
$reader = new Middlewares\Reader($filesystem, $responseFactory, $streamFactory);
$cache = new Filesystem(new LocalFilesystemAdapter(__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 Filesystem(new LocalFilesystemAdapter(__DIR__.'/storage'));
Dispatcher::run([
new Middlewares\Writer($filesystem)
]);
$streamFactory = new MyOwnStreamFactory();
$reader = new Middlewares\Writer($filesystem, $streamFactory);