Skip to content

Commit

Permalink
Composer package
Browse files Browse the repository at this point in the history
Add composer package manifest to publish on packagist
  • Loading branch information
vincepare committed Dec 12, 2015
1 parent 242bdfb commit 24e05fd
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}

0 comments on commit 24e05fd

Please sign in to comment.