Skip to content

Commit

Permalink
Merge pull request #2 from phprtc/dev
Browse files Browse the repository at this point in the history
Updated documentation
  • Loading branch information
Ahmard authored Mar 5, 2022
2 parents 2a86806 + 2c0576d commit ceae89a
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RTC\Watcher
# File Watcher

[Swoole](https://swoole.co.uk) file system changes watcher.
PHP-based file system changes watcher implemented using [**Swoole**](https://swoole.co.uk) & **Inotify**.

## Installation

Expand All @@ -20,12 +20,60 @@ require 'vendor/autoload.php';
Watcher::create()
->addPath(__DIR__ . '/app')
->addPath(__DIR__ . '/views')
//->fileShouldNotEndWith(['.php'])
->onChange(function (EventInfo $eventInfo) {
var_dump($eventInfo->getMask());
});
```

#### Filter
- Make sure that the file whose event is being fired should not end with provided characters.
```php
use RTC\Watcher\Watcher;

require 'vendor/autoload.php';

Watcher::create()
->addPath(__DIR__ . '/app')
->fileShouldNotEndWith(['.php'])
->onChange(function (EventInfo $eventInfo) {
var_dump($eventInfo->getMask());
});
```

- Only listen to event with file name that matches given extension(s).
```php
use RTC\Watcher\Watcher;

require 'vendor/autoload.php';

Watcher::create()
->addPath(__DIR__ . '/app')
->addExtension('php')
->onChange(function (EventInfo $eventInfo) {
var_dump($eventInfo->getMask());
});
```


#### Any-event
Listens to any event on given path

Be careful using this method.

```php
use RTC\Watcher\Watcher;

require 'vendor/autoload.php';

Watcher::create()
->addPath(__DIR__ . '/app')
->onAny(function (EventInfo $eventInfo) {
dump($eventInfo->getMask());
var_dump($eventInfo->getMask());
});
```



#### Swoole Server Integration

```php
Expand Down

0 comments on commit ceae89a

Please sign in to comment.