watcherphp/watcher

Watcher: Effortlessly Track and Manage Your File Changes Seamlessly

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

Language:HTML

pkg:composer/watcherphp/watcher

dev-master 2025-11-09 02:50 UTC

This package is auto-updated.

Last update: 2025-11-09 02:50:23 UTC


README

  • Task not completed
  • Task completed

Full Code:

$file = $argv[1];

$lastModified = filemtime($file);

echo "Watching $file for changes...\n";

while(true){
    clearstatcache();
    
    $currentModified = filemtime($file);
    
    if ($currentModified !== $lastModified) {
        echo "File changed, restarting script...\n";
        
        shell_exec("php $file");
        
        $lastModified = $currentModified;
    }
    
    sleep(1);
}

File Watch Run

php watch index.php