Skip to content

Commit 2c0576d

Browse files
author
ahmard
committed
Updated documentation
1 parent 2a86806 commit 2c0576d

File tree

1 file changed

+52
-4
lines changed

1 file changed

+52
-4
lines changed

README.md

+52-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# RTC\Watcher
1+
# File Watcher
22

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

55
## Installation
66

@@ -20,12 +20,60 @@ require 'vendor/autoload.php';
2020
Watcher::create()
2121
->addPath(__DIR__ . '/app')
2222
->addPath(__DIR__ . '/views')
23-
//->fileShouldNotEndWith(['.php'])
23+
->onChange(function (EventInfo $eventInfo) {
24+
var_dump($eventInfo->getMask());
25+
});
26+
```
27+
28+
#### Filter
29+
- Make sure that the file whose event is being fired should not end with provided characters.
30+
```php
31+
use RTC\Watcher\Watcher;
32+
33+
require 'vendor/autoload.php';
34+
35+
Watcher::create()
36+
->addPath(__DIR__ . '/app')
37+
->fileShouldNotEndWith(['.php'])
38+
->onChange(function (EventInfo $eventInfo) {
39+
var_dump($eventInfo->getMask());
40+
});
41+
```
42+
43+
- Only listen to event with file name that matches given extension(s).
44+
```php
45+
use RTC\Watcher\Watcher;
46+
47+
require 'vendor/autoload.php';
48+
49+
Watcher::create()
50+
->addPath(__DIR__ . '/app')
51+
->addExtension('php')
52+
->onChange(function (EventInfo $eventInfo) {
53+
var_dump($eventInfo->getMask());
54+
});
55+
```
56+
57+
58+
#### Any-event
59+
Listens to any event on given path
60+
61+
Be careful using this method.
62+
63+
```php
64+
use RTC\Watcher\Watcher;
65+
66+
require 'vendor/autoload.php';
67+
68+
Watcher::create()
69+
->addPath(__DIR__ . '/app')
2470
->onAny(function (EventInfo $eventInfo) {
25-
dump($eventInfo->getMask());
71+
var_dump($eventInfo->getMask());
2672
});
2773
```
2874

75+
76+
2977
#### Swoole Server Integration
3078

3179
```php

0 commit comments

Comments
 (0)