tufanbarisyildirim/react-inotify

Inotify bindings for ReactPHP (forked from mkraemer/react-inotify)
41
Install
composer require tufanbarisyildirim/react-inotify
Latest Version:v1.0.0
PHP:>=5.4.0
License:MIT
Last Updated:Jan 9, 2015
Links: GitHub  ·  Packagist
Maintainer: tufan

React-Inotify

Basic inotify bindings for React PHP.

##Install This library requires PHP5.3 and the inotify PECL extension. The best way to install this library is through composer:

{
    "require": {
        "tufanbarisyildirim/react-inotify": "dev-master"
    }
}

Usage

This library provides the Inotify class which takes an event loop and optionally the timer interval in which the inotify events should be checked as constructor arguments. After initializing the class, you can use the add() method to add paths to the list of watched paths. Use the inotify bitmasks to define to which filesystem operations to listen.

<?php

$loop = React\EventLoop\Factory::create();
$inotify = new MKraemer\ReactInotify\Inotify($loop);

$inotify->add('/tmp/', IN_CLOSE_WRITE | IN_CREATE | IN_DELETE);
$inotify->add('/var/log/', IN_CLOSE_WRITE | IN_CREATE | IN_DELETE);

$inotify->on(IN_CLOSE_WRITE, function ($path) {
    echo 'File closed after writing: '.$path.PHP_EOL;
});

$inotify->on(IN_CREATE, function ($path) {
    echo 'File created: '.$path.PHP_EOL;
});

$inotify->on(IN_DELETE, function ($path) {
    echo 'File deleted: '.$path.PHP_EOL;
});

$loop->run();

Related Packages

particle-academy/fancy-starter-kit

A Laravel + Inertia + React 19 + Tailwind v4 starter kit with Fancy UI (Fancy Co...

27 2
lattice-php/lattice

Server-driven React components for Laravel and Inertia.

2,556 0
hadyfayed/filament-workflow-canvas

Visual workflow builder and canvas component for FilamentPHP applications

5 3
sansanlabs/laravel-antd-starter-kit

A Laravel starter kit with Ant Design, Inertia, React, and TypeScript optimized...

19 0
shopper/starter-kits

Minimum scaffolding starter kit for Shopper e-commerce

754 17