PHP code example of degraciamathieu / php-file-explorer

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

    

degraciamathieu / php-file-explorer example snippets


use DeGraciaMathieu\FileExplorer\FileFinder;

$fileFinder = new FileFinder(
    basePath: __DIR__,
);

$files = $fileFinder->getFiles();

foreach ($files as $file) {

   # DeGraciaMathieu\FileExplorer\File
   $file->fullPath;
   $file->displayPath;
}

$fileFinder = new FileFinder(
    basePath: 'app/Modules/', 
    onlyPatterns: [
        '.*/Logics/.*',
        '.*Logic.php',
    ],
);

$files = $fileFinder->getFiles();

$fileFinder = new FileFinder(
    basePath: 'app/Modules/', 
    ignorePatterns: [
        '.*/Repositories/.*',
    ],
);

$files = $fileFinder->getFiles();

$fileFinder = new FileFinder(
    basePath: 'app/', 
);

$files = $fileFinder->getFiles([
    'Models/.*',
    'Services/.*',
]);