1. Go to this page and download the library: Download acidwave/yii2-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\Visibility;
Yii::$app->fs->write('filename.ext', 'contents', [
'visibility' => Visibility::PRIVATE
]);
use League\Flysystem\Visibility;
if (Yii::$app->fs->visibility('filename.ext') === Visibility::PRIVATE) {
Yii::$app->fs->setVisibility('filename.ext', Visibility::PUBLIC);
}
$contents = Yii::$app->fs->listContents('path/to/directory');
foreach ($contents as $object) {
echo basename($object->path())
. ' is located at' . $object->path()
. ' and is a ';
if ($object instanceof \League\Flysystem\FileAttributes) {
echo 'file' . PHP_EOF;
} elseif ($object instanceof \League\Flysystem\DirectoryAttributes) {
echo 'directory' . PHP_EOF;
}
}