PHP code example of webdevcave / directory-crawler
1. Go to this page and download the library: Download webdevcave/directory-crawler 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/ */
webdevcave / directory-crawler example snippets
ebdevCave\DirectoryCrawler\Crawler;
// Set the directory path to crawl
$path = '/path/to/directory';
$crawler = new Crawler($path);
// Get all files and directories
$contents = $crawler->contents();
// Get all files
$files = $crawler->files();
// Get all directories
$directories = $crawler->directories();
// List classes inside the directories
$namespace = 'My\\Project\\';
$enforce = false; //Faster
//$enforce = true; //Reliable but slower. May cause performance issues, depending on the number of occurrences.
$classes = $crawler->classes($namespace, $enforce);
print_r(compact('path', 'contents', 'files', 'directories', 'classes')); //Show results
bash
composer