Application Filesystem¶
The Webino™ filesystem provides simple to use drivers for working with local filesystems, Azure, Amazon S3, Copy.com, Dropbox, (S)FTP, GridFS, Memory, Rackspace, WebDAV, PHPCR and ZipArchive. [TODO]
- Powered by Flysystem
Filesystem Interface¶
- $app->getFilesystems()
- $app->file()
- $app->file()->write()
- $app->file()->update()
- $app->file()->put()
- $app->file()->read()
- $app->file()->has()
- $app->file()->delete()
- $app->file()->readAndDelete()
- $app->file()->rename()
- $app->file()->copy()
- $app->file()->getMimetype()
- $app->file()->getTimestamp()
- $app->file()->getSize()
- $app->file()->createDir()
- $app->file()->deleteDir()
- $app->file()->emptyDir()
- $app->file()->listContents()
- $app->file()->listPaths()
- $app->file()->listFiles()
- $app->file()->writeStream()
- $app->file()->updateStream()
- $app->file()->putStream()
- $app->file()->readStream()
Note
All paths used by Filesystem API are relative to its adapter root directory.
$app->getFilesystems()¶
Accessing filesystem manager service.
/** @var \Zend\ServiceManager\ServiceLocatorInterface $filesystems */
$filesystems = $app->getFilesystems();
$app->file()¶
Obtaining filesystem instance.
use WebinoAppLib\Filesystem\LocalFiles;
use WebinoAppLib\Filesystem\InMemoryFiles;
// default filesystem
$localFiles = $app->file();
// or
$localFiles = $app->file(LocalFiles::class);
// different filesystem
$inMemoryFiles = $app->file(InMemoryFiles::class);
$app->file()->write()¶
Write files, throws an exception if the file already exists.
$app->file()->write('path/to/file.txt', 'File content example.');
$app->file()->update()¶
Update files, throws an exception if the file does not exists.
$app->file()->update('path/to/file.txt', 'File content example updated.');
$app->file()->put()¶
Write or update files.
$app->file()->put('path/to/file.txt', 'File content example.');
$app->file()->readAndDelete()¶
Read and delete files.
$contents = $app->file()->readAndDelete('path/to/file.txt');
$app->file()->rename()¶
Rename files.
$app->file()->rename('path/to/file.txt', 'path/to/new-file.txt');
$app->file()->getMimetype()¶
Get MIME types.
$mimetype = $app->file()->getMimetype('path/to/file.txt');
$app->file()->getTimestamp()¶
Get timestamps.
$timestamp = $app->file()->getTimestamp('path/to/file.txt');
$app->file()->createDir()¶
Create directories.
$app->file()->createDir('path/to/new/directory');
Directories are also made implicitly when writing to a deeper path.
$app->file()->write('path/to/file.txt', 'File content example.');
$app->file()->listContents()¶
List contents, returns array of info of the files and folders.
$contents = $app->file()->listContents('path/to/directory', $recursive = false);
// non-recursive root by default
$contents = $app->file()->listContents();
$app->file()->listPaths()¶
List paths, returns array of paths of the files and folders.
$paths = $app->file()->listPaths('path/to/directory', $recursive = false);
// non-recursive root by default
$paths = $app->file()->listPaths();
$app->file()->listFiles()¶
List files, returns array of paths of the files.
$files = $app->file()->listFiles('path/to/directory', $recursive = false);
// non-recursive root by default
$files = $app->file()->listFiles();
$app->file()->writeStream()¶
Write files using stream, throws an exception if the file already exists.
$app->file()->writeStream('path/to/file.txt', $stream);
$app->file()->updateStream()¶
Update files using stream, throws an exception if the file does not exists.
$app->file()->updateStream('path/to/file.txt', $stream);
$app->file()->putStream()¶
Write or update files using stream.
$app->file()->putStream('path/to/file.txt', $stream);
$app->file()->readStream()¶
Read files using stream.
$stream = $app->file()->readStream('path/to/file.txt');
Filesystem Config¶
DefaultFilesystem¶
Overriding default local working dir filesystem.
use WebinoAppLib\Feature\DefaultFilesystem;
Webino::config([
// optional
new DefaultFilesystem('custom/root'),
]);
See also
MemoryFilesystem¶
Configuring temporary filesystem in the memory.
use WebinoAppLib\Feature\MemoryFilesystem;
Webino::config([
new MemoryFilesystem,
]);
See also
Configuring Filesystem¶
TODO…
Working With Streams¶
TODO…