Skip to content

Run through a directory with event-emitting along the way

License

Notifications You must be signed in to change notification settings

kompakt/directory-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kompakt\DirectoryRunner

Run through a directory with event-emitting along the way.

Install

Through Composer:

  • composer require kompakt/directory-runner

Example

Iterate over all json files in a given directory:

use Kompakt\DirectoryRunner\Subscriber\Debugger;
use Kompakt\DirectoryRunner\Runner;
use Kompakt\DirectoryRunner\EventNames;
use Symfony\Component\EventDispatcher\EventDispatcher;

$dir = 'path/to/dir';

$dispatcher = new EventDispatcher();
$eventNames = new EventNames();
$runner = new Runner($dispatcher, $eventNames, $dir);
$debugger = new Debugger($dispatcher, $eventNames);
$debugger->activate();

$callback = function($fileInfo)
{
    return preg_match('/\.json$/', $fileInfo->getFilename());
};

$runner->run($callback);

License

kompakt/directory-runner is licensed under the MIT license - see the LICENSE file for details

About

Run through a directory with event-emitting along the way

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages