Пример #1
0
 protected function startWatcher()
 {
     $watcher = Watcher::factory($this->directoryToWatch);
     $watcher->registerExtensionToWatch('php');
     $watcher->onSave(function ($file) {
         $this->consoleOutput->writeln("File saved: <info>{$file}</info>");
         $this->onSaveCallback($file);
     });
     $watcher->onDelete(function ($file) {
         $this->consoleOutput->writeln("File deleted: <info>{$file}</info>");
         $this->onDeleteCallback($file);
     });
     $watcher->onCreate(function ($file) {
         $this->consoleOutput->writeln("File created: <info>{$file}</info>");
         $this->onCreateCallback($file);
     });
     $watcher->start();
 }
Пример #2
0
<?php

include __DIR__ . '/../vendor/autoload.php';
use FsWatcher\Watcher;
use Sh\Sh;
$directoryToWatch = './';
$sh = new Sh();
$watcher = Watcher::factory($directoryToWatch);
$watcher->registerExtensionToWatch('php');
$watcher->onSave(function ($file) use($sh) {
    echo $sh->php("-l {$file}");
    echo "\n";
});
$watcher->onDelete(function ($file) {
    echo "DELETED: {$file}\n";
});
$watcher->onCreate(function ($file) {
    echo "CREATED: {$file}\n";
});
$watcher->start();