1. Go to this page and download the library: Download vox/file-watcher 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/ */
vox / file-watcher example snippets
use Vox\FileWatcher\FolderWatcherContext;
use Vox\FileWatcher\FolderWatcher;
$context = new FolderWatcherContext();
$context->blocking = true; //if set to false, php will not block when readEvents is called, async code can be done
$context->recursive = true; //if set to true subfolders will be also watched,
//and so new subfolders will be automatically be watched
$watcher = new FolderWatcher('/folder/to/watch', $context);
$watcher->onCreated(function (FileWatcherEvent $event, FolderWatcherContext $context) {
//do something when a file is created
});
$watcher->dispatchEvents();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.