PHP code example of octopyid / laravel-inotify

1. Go to this page and download the library: Download octopyid/laravel-inotify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

octopyid / laravel-inotify example snippets


use Octopy\Inotify\Inotify;
use Octopy\Inotify\Contract\Event;
use Octopy\Inotify\Contract\Watcher;

$inotify = new Inotify('foo.txt');

$inotify->event(function (Event $event) {

    $event->on(IN_MODIFY, function (Watcher $watcher) {
        // do something
    });
    
    $event->on(IN_DELETE, function (Watcher $watcher) {
        // do something
    });

    // see : https://www.php.net/manual/en/inotify.constants.php for more events.
});

$inotify->watch();