alb/php-inotify-ffi

Pure-PHP inotify bindind (FFI-based)

dev-main 2020-12-18 15:50 UTC

This package is auto-updated.

Last update: 2024-03-18 23:08:21 UTC


README

php-inotify-ffi is a pure-PHP inotify binding based on FFI.

Experimental / WIP

This is an experimental / WIP package. For a stable inotify binding, use php-inotify.

Goal

The goal of this package is to expose the raw inotify API to PHP, while being memory safe and preventing resource leaks.

Streams

As the C inotify API returns file descriptors, this package returns PHP streams.

This is useful for the following reasons:

I/O Polling

The streams can be used with polling mechanisms such as stream_select() or event loops such as ReactPHP or AMPHP. It's also possible to make the streams unblocking with stream_set_blocking().

Resource management

As the inotify file descriptors are owned by PHP streams, they are managed by PHP. This ensures that the file descriptors are eventually closed, which prevents descriptor leaks.

Comparison with the PECL extension

The extension is stable and has the same capabilities.