PHP code example of mkraemer / react-inotify
1. Go to this page and download the library: Download mkraemer/react-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/ */
mkraemer / react-inotify example snippets
$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();