1. Go to this page and download the library: Download kompas/flysystem 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\Local as Adapter;
$filesystem = new Filesystem(new Adapter(__DIR__.'/path/to/root'));
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Zip as Adapter;
$filesystem = new Filesystem(new Adapter(__DIR__.'/path/to/archive.zip'));
use Aws\S3\S3Client;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\AwsS3 as Adapter;
$client = S3Client::factory(array(
'key' => '[your key]',
'secret' => '[your secret]',
));
$filesystem = new Filesystem(new Adapter($client, 'bucket-name', 'optional-prefix'));
use OpenCloud\OpenStack;
use OpenCloud\Rackspace;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Rackspace as Adapter;
$client = new OpenStack(Rackspace::UK_IDENTITY_ENDPOINT, array(
'username' => ':username',
'password' => ':password',
));
$store = $client->objectStoreService('cloudFiles', 'LON');
$container = $store->getContainer('flysystem');
$filesystem = new Filesystem(new Adapter($container));
$filesystem = new Filesystem(new Adapter\Rackspace($container, 'prefix'));
use Dropbox\Client;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Dropbox as Adapter;
$client = new Client($token, $appName);
$filesystem = new Filesystem(new Adapter($client, 'optional/path/prefix'));
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Sftp as Adapter;
$filesystem = new Filesystem(new Adapter(array(
'host' => 'example.com',
'port' => 21,
'username' => 'username',
'password' => 'password',
'privateKey' => 'path/to/or/contents/of/privatekey',
'root' => '/path/to/root',
'timeout' => 10,
)));
$client = new Sabre\DAV\Client($settings);
$adapter = new League\Flysystem\Adapter\WebDav($client);
$flysystem = new League\Flysystem\Filesystem($adapter);
$adapter = new League\Flysystem\Adapter\NullAdapter;
$flysystem = new League\Flysystem\Filesystem($adapter);
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as Adapter;
use League\Flysystem\Cache\Predis as Cache;
$filesystem = new Filesystem(new Adapter(__DIR__.'/path/to/root'), new Cache);
// Or supply a client
$client = new Predis\Client;
$filesystem = new Filesystem(new Adapter(__DIR__.'/path/to/root'), new Cache($client));
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as Adapter;
use League\Flysystem\Cache\Memcached as Cache;
$memcached = new Memcached;
$memcached->addServer('localhost', 11211);
$filesystem = new Filesystem(new Adapter(__DIR__.'/path/to/root'), new Cache($memcached, 'storageKey', 300));
// Storage Key and expire time are optional
use Dropbox\Client;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Dropbox;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Cache\Adapter;
$client = new Client('token', 'app');
$dropbox = new Dropbox($client, 'prefix');
$local = new Local('path');
$cache = new Adapter($local, 'file', 300);
// Expire time is optional
$filesystem = new Filesystem($dropbox, $cache);
use League\Flysystem\FilesystemInterface;
use League\Flysystem\PluginInterface;
class MaximusAwesomeness implements PluginInterface
{
protected $filesystem;
public function setFilesystem(FilesystemInterface $filesystem)
{
$this->filesystem = $filesystem;
}
public function getMethod()
{
return 'getDown';
}
public function handle($path = null)
{
$contents = $this->filesystem->read($path);
return sha1($contents);
}
}
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter;
$filesystem = new Filesystem(new Adapter\Local(__DIR__.'/path/to/files/'));
$filesystem->addPlugin(new MaximusAwesomeness);
$sha1 = $filesystem->getDown('path/to/file');
$ftp = new League\Flysystem\Filesystem($ftpAdapter);
$s3 = new League\Flysystem\Filesystem($s3Adapter);
$local = new League\Flysystem\Filesystem($localAdapter);
// Add them in the constructor
$manager = new League\Flysystem\MountManager(array(
'ftp' => $ftp,
's3' => $s3,
));
// Or mount them later
$manager->mountFilesystem('local', $local);
// Read from FTP
$contents = $manager->read('ftp://some/file.txt');
// And write to local
$manager->write('local://put/it/here.txt', $contents);