Bånder

FileWatcher
in package

Table of Contents

Properties

$callbacks  : array<string|int, mixed>
$inotify  : InotifyWrapper
$running  : bool

Methods

__construct()  : mixed
__destruct()  : mixed
Destructor
getStats()  : array<string|int, mixed>
Get watch statistics
isAvailable()  : bool
Check if file watching is available
onEvent()  : void
Add a callback for file events
poll()  : int
Poll for events (non-blocking)
start()  : void
Start watching files/directories
stop()  : void
Stop watching and cleanup
waitForEvents()  : int
Watch for events with timeout
watch()  : int
Add a path to watch
triggerCallbacks()  : void
Trigger all registered callbacks

Properties

$callbacks

private array<string|int, mixed> $callbacks = []

Methods

__destruct()

Destructor

public __destruct() : mixed

getStats()

Get watch statistics

public getStats() : array<string|int, mixed>
Return values
array<string|int, mixed>

isAvailable()

Check if file watching is available

public isAvailable() : bool
Return values
bool

onEvent()

Add a callback for file events

public onEvent(Closure $callback) : void
Parameters
$callback : Closure

Function to call when events occur Receives (string $path, array $event) parameters

poll()

Poll for events (non-blocking)

public poll() : int
Return values
int

Number of events processed

stop()

Stop watching and cleanup

public stop() : void

waitForEvents()

Watch for events with timeout

public waitForEvents([int $timeoutMicroseconds = 100000 ]) : int
Parameters
$timeoutMicroseconds : int = 100000

Timeout in microseconds

Return values
int

Number of events processed

watch()

Add a path to watch

public watch(string $path[, array<string|int, mixed> $events = ['IN_MODIFY', 'IN_CREATE', 'IN_DELETE'] ][, bool $recursive = false ]) : int
Parameters
$path : string

Path to watch

$events : array<string|int, mixed> = ['IN_MODIFY', 'IN_CREATE', 'IN_DELETE']

Events to watch for (e.g., ['IN_MODIFY', 'IN_CREATE'])

$recursive : bool = false

Watch recursively for directories

Tags
throws
InotifyException
Return values
int

Number of watches added

triggerCallbacks()

Trigger all registered callbacks

private triggerCallbacks(string $path, array<string|int, mixed> $event) : void
Parameters
$path : string
$event : array<string|int, mixed>

        
On this page

Search results