An open API service indexing awesome lists of open source software.

https://github.com/cydrickn/php-watcher

A simple directory and file watcher that was made using PHP.
https://github.com/cydrickn/php-watcher

php php-watcher watcher

Last synced: about 1 year ago
JSON representation

A simple directory and file watcher that was made using PHP.

Awesome Lists containing this project

README

          

# PHP Watcher

A simple directory and file watcher that was made using PHP.

## Requirements

* PHP >= 8.1

## Installation

```shell
composer require cydrickn/php-watcher
```

## Usage

To use this package you just need to initialize the watcher and call the tick function

```php
tick();
```

## Adapters

Currently, we have 3 premade adapters:

### \Cydrickn\PHPWatcher\Adapters\SwooleTimerAdapter

If you are using Swoole/Openswoole then best choice to use this adapter

### \Cydrickn\PHPWatcher\Adapters\NativeAdapter

If not using Swoole/Openswoole then you can go for this one, it uses PHP's do-while and sleep

### \Cydrickn\PHPWatcher\Adapters\HybridAdapter

This is same as the version 1 where it will automatically use the SwooleTimerAdapter, if available or fallback to NativeAdapter.
This might be useful in a mixed environment.

## Custom Adapter

If you don't want to use any pre-made adapter you can create your own adapter.
Example:

```php