1. Go to this page and download the library: Download yiisoft/files 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/ */
yiisoft / files example snippets
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
FileHelper::ensureDirectory($directory);
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
FileHelper::ensureDirectory($directory, 0775);
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
FileHelper::removeDirectory($directory);
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
FileHelper::clearDirectory($directory, [
'traverseSymlinks' => false,
'filter' => (new PathMatcher())
->only('**.png', '**.jpg')
->except('**/logo.png'),
]);
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
FileHelper::isEmptyDirectory($directory);
use \Yiisoft\Files\FileHelper;
$source = '/path/to/source';
$destination = '/path/to/destination';
FileHelper::copyDirectory($source, $destination);
use \Yiisoft\Files\FileHelper;
$source = '/path/to/file';
$destination = '/path/to/destination';
FileHelper::copyFile($source, $destination);
use \Yiisoft\Files\FileHelper;
use Yiisoft\Files\PathMatcher\PathMatcher;
$files = FileHelper::findFiles('/path/to/where/to/search', [
'filter' => (new PathMatcher())
->only('**.png', '**.jpg')
->except('**/logo.png'),
]);
use \Yiisoft\Files\FileHelper;
use Yiisoft\Files\PathMatcher\PathMatcher;
$directories = FileHelper::findDirectories('/path/to/where/to/search', [
'filter' => (new PathMatcher())->except('**meta'),
]);
use \Yiisoft\Files\FileHelper;
$handler = FileHelper::openFile('/path/to/file', 'rb');
use \Yiisoft\Files\FileHelper;
$directory = '/path/to/dir';
$time = FileHelper::lastModifiedTime($directory);
use \Yiisoft\Files\FileHelper;
$file = '/path/to/file.txt';
FileHelper::unlink($file);