How to track file changes using HHVM?

PHP has an extension inotify

, but HHVM does not support it.

How can I monitor the file, at least for an event IN_CLOSE_WRITE

on HHVM?

<?php // sample inotify code for PHP

$fd = inotify_init();
$watch_descriptor = inotify_add_watch($fd, __FILE__, IN_ATTRIB);
touch(__FILE__); // generate an event
$events = inotify_read($fd);
var_dump($events);

      

+3


source to share


1 answer


As you discovered, the Inotify extension is currently not supported in HHVM. Perhaps the HHVM community will write an HNI extension that supports the API. HHVM already uses inotify, when available, internally for its statcache code (e.g. for lstat () caching). So the build environment is already set up to detect the availability of inotify. Using this would make it easier to create a native extension starting from scratch.



Until then, one alternative might be to use the watchdog in conjunction with your PHP code. In the push model, watchman executes a PHP script based on the triggers you configured earlier. In the pull / poll model, you can request a watchdog over a socket. One of the benefits of using watchman is that it supports more operating systems than just Linux. The performance of using watchman versus the internal inotify extension will be workload dependent.

+3


source







All Articles