1
- # RTC\ Watcher
1
+ # File Watcher
2
2
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 ** .
4
4
5
5
## Installation
6
6
@@ -20,12 +20,60 @@ require 'vendor/autoload.php';
20
20
Watcher::create()
21
21
->addPath(__DIR__ . '/app')
22
22
->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')
24
70
->onAny(function (EventInfo $eventInfo) {
25
- dump ($eventInfo->getMask());
71
+ var_dump ($eventInfo->getMask());
26
72
});
27
73
```
28
74
75
+
76
+
29
77
#### Swoole Server Integration
30
78
31
79
``` php
0 commit comments