From 24e05fddca23a4c232d7494d85aa694e03abb085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Par=C3=A9?= Date: Sat, 12 Dec 2015 22:39:35 +0100 Subject: [PATCH] Composer package Add composer package manifest to publish on packagist --- README.md | 30 ++++++++++++++++++++++++++++++ composer.json | 24 ++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 composer.json diff --git a/README.md b/README.md index 20b37e5..9c3d287 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,36 @@ Format tokens to customize output (`--format`) : %e Extended ``` +### Programmatic use +Although dirscan is released as a command line tool, you can also use its internal `DirScan` class as a file system iterator. Dirscan is available as a composer package : +``` +composer require vincepare/dirscan +``` + +##### How to use +```php +require 'vendor/autoload.php'; + +use Vincepare\DirScan\DirScan; +use Vincepare\DirScan\Reporter; + +class MyReporter extends Reporter +{ + public $files = []; + + public function push($node, DirScan $scanner) + { + $this->files[] = $node['path']; + } +} + +$settings = ['flat' => true]; +$reporter = new MyReporter(); +$scanner = new DirScan($settings, $reporter); +$scanner->scan('/tmp'); +print_r($reporter->files); +``` + ### About windows DirScan is designed to work on a Unix environment (Linux or Mac OS) but you can also use it on Windows. In this case, beware of NTFS junction points and symbolic links that are not handled properly by old php releases (see [readlink](http://php.net/manual/en/function.readlink.php) & [is_link](http://php.net/manual/en/function.is-link.php)). But you'd better use other tools like [WhereIsIt](http://www.whereisit-soft.com/). diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..29d7092 --- /dev/null +++ b/composer.json @@ -0,0 +1,24 @@ +{ + "name": "vincepare/dirscan", + "description": "File system scanner", + "type": "project", + "time": "2015-12-12", + "license": "Apache-2.0", + "keywords": ["filesystem","iterator","reporting"], + "homepage": "https://github.com/vincepare/DirScan", + "authors": [ + { + "name": "Vincent Paré", + "email": "opensource@finalclap.com", + "homepage": "http://www.finalclap.com/" + } + ], + "require": { + "php": ">=5.3.0" + }, + "autoload": { + "psr-4": { + "Vincepare\\DirScan\\": "src" + } + } +}