1. Go to this page and download the library: Download molajo/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/ */
molajo / filesystem example snippets
// Instantiate Handler (example local) and pass it into the Filesystem Adapter
use Molajo\Filesystem\Handler\Local;
$handler = new Local();
use Molajo\Filesystem\Adapter;
$adapter = new Adapter($handler);
$true_or_false = $adapter->exists('\file\located\here.txt');
$metadata = $adapter->getMetadata('\file\located\here.txt');
echo $metadata->owner; // See complete list of metadata returned, below
$contents_of_file = $adapter->read('\file\located\here.txt');
$list_of_results = $adapter->getList($path, $recursive, $extension_list,
$
use Molajo\Filesystem\Handler\Local;
$handler = new Local();
use Molajo\Filesystem\Adapter;
$adapter = new Adapter($handler);
try {
$results = $adapter->read('\file\located\here.txt');
} catch (Exception $e) {
// deal with the exception
}
try {
$exists = $adapter->exists($path);
} catch (Exception $e) {
// deal with the exception
}
if ($exists === true) {
echo 'The file or folder defined in $path does exist.';
} else {
echo 'The file or folder defined in $path does NOT exist.';
}
try {
$metadata = $adapter->getMetadata($path);
} catch (Exception $e) {
// deal with the exception
}
// View all object properties returned
// Use a single element
echo $metadata->name;
try {
$results = $adapter->read('\file\located\here.txt');
} catch (Exception $e) {
// deal with the exception
}