Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP folder watching on windows

I am writing a simple PHP script to watch a folder and its subfolders for any changes (new files, modifications, deletions) and then perform an action.

I will run this script from the commandline on windows using php -f script.php.

I have been search for a way to watch folders on windows that has PHP bindings. Something like inotify or gamin for windows would be nice.

The answers to this question mentions FindFirstChangeNotification, but I couldn't find any PHP bindings for it.

Are there any libraries/software for folder/filesystem watching on windows with PHP bindings?

like image 293
F21 Avatar asked Feb 28 '26 11:02

F21


1 Answers

I ended up just writing a simple function using the RecursiveDirectoryIterator that is called in an infinit loop.

All I have to do is check the last modified time of the file or a folder and return true or false.

This isn't a very exact approach, but it serves my purposes well. Sitting in the back ground, the script uses about 12MB of ram.

like image 89
F21 Avatar answered Mar 03 '26 00:03

F21



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!