Download the PHP package symplely/uv-ffi without Composer
On this page you can find all versions of the php package symplely/uv-ffi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download symplely/uv-ffi
More information about symplely/uv-ffi
Files in symplely/uv-ffi
Package uv-ffi
Short Description Foreign Function Interface (FFI) of `libuv` cross-platform event-driven asynchronous I/O library.
License MIT
Homepage https://github.com/symplely/uv-ffi
Informations about the package uv-ffi
uv-ffi
An Foreign function interface (FFI) for PHP of libuv cross-platform event-driven asynchronous I/O library.
This libuv ffi implementation is based on PHP extension ext-uv. All ext-uv 0.3.0 tests and functions been implemented, except uv_queue_work.
- Functionality works as expected under
Windows
,Linux
, andApple macOS
, PHP 7.4 to 8.2. - All functionality is interdependent on zend-ffi.
The actual threading feature of uv_queue_work
in ext-uv 0.3.0 is on pause. Getting native PThreads working with FFI, needs a lot more investigation and more likely C development of PHP source code. Seems someone else has started something similar https://github.com/mrsuh/php-pthreads.
Update: Since progress by maintainers of amphp/ext-uv has stopped. See symplely/ext-uv for updates, a new release version 0.4.2 with true threading feature of uv_queue_work()
implemented, other bugs, and build issues fixed. Pre-built binaries available for most platforms at https://github.com/symplely/ext-uv/releases, the whole pecl
build system not needed, and PHP versions 7.4 to 8.2 supported.
PR are welcome, see [Documentation] and [Contributing].
Future versions of uv-ffi
beyond ext-uv 0.3.0 will include all current libuv
features.
Installation
There will be two ways: composer require symplely/uv-ffi and: composer create-project symplely/uv-ffi .cdef/libuv
This package/repo is self-contained for Windows and Apple macOS, meaning it has GitHub Actions building libuv
binary .dll
& .dylib
, and committing back to repo. The other platforms will use the distributions included libuv
binary version.
The create-project
will setup a different loading/installation area. This feature is still a work in progress.
Minimum php.ini
setting:
How to use
- The functions in file UVFunctions.php is the only means of accessing libuv features.
The following is a PHP tcp echo server
converted from C
uv book that's follows also. Most of the required C
setup and cleanup code is done automatically.
This will print "Got a connection!" to console if visited.
The C source
Error handling
Initialization functions *_init()
or synchronous functions, which may fail will return a negative number on error.
Async functions that may fail will pass a status parameter to their callbacks. The error messages are defined as UV::E*
constants.
You can use the uv_strerror(int)
and uv_err_name(int)
functions to get a string
describing the error or the error name respectively.
I/O read callbacks (such as for files and sockets) are passed a parameter nread
. If nread
is less than 0, there was an error (UV::EOF
is the end of file error, which you may want to handle differently).
In general, functions and status parameters contain the actual error code, which is 0 for success, or a negative number in case of error.
Documentation
All functions/methods/classes
have there original Libuv documentation, signatures embedded in DOC-BLOCKS.
For deeper usage understanding, see An Introduction to libuv.
The following functions are present in Windows, but not in Linux ubuntu 20.04 up, might need rechecking though.
Contributing
Contributions are encouraged and welcome; I am always happy to get feedback or pull requests on Github :) Create Github Issues for bugs and new features and comment on the ones you are interested in.
License
The MIT License (MIT). Please see License File for more information.