PHP code example of halimonalexander / filesystem

1. Go to this page and download the library: Download halimonalexander/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/ */

    

halimonalexander / filesystem example snippets


use HalimonAlexander\Filesystem\Filesystem;
use HalimonAlexander\Filesystem\Filters\ExtensionFilter;

$filesystem = new Filesystem();
$files = $filesystem
    ->enter('/var/log/mysql/')
    ->files()
    ->filter(new ExtensionFilter('log'))
    ->get();

$folders = $filesystem
    ->enter('/var/www/app/')
    ->directories()
    ->get();

$foldersWithFiles = $filesystem
    ->enter('/etc/nginx/')
    ->get();

use HalimonAlexander\Filesystem\Filesystem;
use HalimonAlexander\Filesystem\Filters\ExtensionFilter;

$filesystem = new Filesystem();
$files = $filesystem
    ->enter('/var/log/mysql/')
    ->files()
    ->filter(new ExtensionFilter('log'))
    ->get();

use HalimonAlexander\Filesystem\Filesystem;
use HalimonAlexander\Filesystem\Filters\RegexpFilter;

$filesystem = new Filesystem();
$files = $filesystem
    ->enter('/var/log/mysql/')
    ->filter(new RegexpFilter('2020-01-01(.*)'))
    ->get();

use HalimonAlexander\Filesystem\Filesystem;
use HalimonAlexander\Filesystem\Filters\ExtensionFilter;
use HalimonAlexander\Filesystem\Filters\RegexpFilter;

$filesystem = new Filesystem();
$files = $filesystem
    ->enter('/var/log/mysql/')
    ->files()
    ->filter(new ExtensionFilter('log'))
    ->filter(new RegexpFilter('2020-01-\d{2}.*'))
    ->filter(new RegexpFilter('\d{4}-\d{2}-d{2}_1.*'))
    ->get();