Learning where to use FFI
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!
Tip
For information on the TensorFlow machine learning platform, head over to this web page: https://www.tensorflow.org/. To see how PHP can be bound to this library, have a look here: https://github.com/dstogov/php-tensorflow.
As we show you in this section, the FFI extension is not a magic solution for all of your needs. This section discusses the main strengths and weaknesses of the FFI extension, as well as giving you 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.
Adopting FFI into PHP
The first FFI extension was actually introduced for PHP...