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?
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.