Learning Where to Use FFI

Learn about when FFI was introduced, the reasons to use it, and the reasons not to.

The potential for importing C libraries directly into PHP is truly staggering. One of the PHP core developers actually used the FFI extension to bind PHP to the C-language TensorFlow machine learning platform!

As we show in this section, the FFI extension is not a magic solution for all of our needs. This section discusses the main strengths and weaknesses of the FFI extension, as well as gives us guidelines for its use. A myth we debunk in this section is that making direct C-language calls using the FFI extension speeds up PHP 8 program execution. First, let’s have a look at what took so long to get the FFI extension into PHP.

...