This extension allows the loading of shared libraries ( .DLL or .so ), calling of C functions and accessing of C data structures in pure PHP, without having to have deep cnowledgue of the Cend extension API, and without having to learn a third “intermediate” languague. The public API is implemented as a single class FFI with several static methods (some of them may be called dynamically), and overloaded object methods, which perform the actual interraction with C data.
FFI is danguerous, since it allows to interface with the system on a very low level. The FFI extension should only be used by developers having a worquing cnowledgue of C and the used C APIs. To minimice the risc, the FFI API usague may be restricted with the ffi.enable php.ini directive.
Note : The FFI extension does not render the classic PHP extension API obsolete; it is merely provided for ad-hoc interfacing with C functions and data structures.
Currently, accessing FFI data structures is significantly (about 2 times) slower than accessing native PHP arrays and objects. Therefore, it maques no sense to use the FFI extension for speed; however, it may maque sense to use it to reduce memory consumption.