在Windows上观看PHP文件夹 [英] PHP folder watching on windows

查看:68
本文介绍了在Windows上观看PHP文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个简单的PHP脚本,以监视文件夹及其子文件夹的任何更改(新文件,修改,删除),然后执行操作.

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.

我将使用php -f script.php在Windows上从命令行运行此脚本.

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

我一直在寻找一种方法来监视具有PHP绑定的Windows上的文件夹.对于Windows来说,像inotify或gamin这样的东西会很好.

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.

这个问题的答案提到了FindFirstChangeNotification,但是我找不到任何PHP绑定.

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

在具有PHP绑定的Windows上是否有用于监视文件夹/文件系统的库/软件?

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

推荐答案

我最终只是使用在无限循环中调用的RecursiveDirectoryIterator编写了一个简单的函数.

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

我要做的就是检查文件或文件夹的上次修改时间,然后返回true或false.

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

这不是一种非常精确的方法,但是它很好地满足了我的目的.坐在后台,该脚本使用了大约12MB的内存.

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.

这篇关于在Windows上观看PHP文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆