To conclude this mini technical file on PHP's foreign
functions interface, I set out to simply connect to a
lib. A kind of challenge that could at the same time help me
progress on the topic. So I had to come up with a project
idea. Something not too small or too simple but also not too big.
Failed, I found an idea but this turns out to be much more complex
than I imagined. No matter, I still tried. So for our article, I
thought I would attempt...
PHP/Docker Configuration
If you are developing with Symfony, installed in a docker compose
and still not using the debugger, then this article is for you. We
are going to show you how to prepare your environment so you no
longer have to do dd() or var_dump. Once you have tasted the joys
of debugging, you won't be able to do without it, as it will
greatly enhance your comfort.
For this article you need to have a Symfony app powered by
apache/php (or nginx and...
With Stéphane Péchard https://www.linkedin.com/in/stephanepechard/, Android expert and KMP guru, we wondered if developing an algorithm under KMP and executing it directly in PHP would be feasible. The specifications were simple: the Android dev (Stéphane) provides me with a header file, a .so file and I handle it. With the header file, the contract, we should be able to come up with something... So we managed to make our function call. But to be honest, I still strug...
The CallbackDuring the preparation of this article, I noticed that many resources on the internet directly use the libc for their examples. You can easily find fairly demonstrative and simple examples. But to do something cool and original, I thought to myself "let's find something to show with this libc too". After all… if it's just passing a structure as most examples do, it won't be useful. And then I came across a function in a forum where people were ...
Calling the PHP library directly?What if we had fun writing a piece of code that is useless? Come on!!! Come on!! Come on!!!Alright OK. I propose we do something useless by using PHP to call a C library that uses the Zend Engine.Actually, this paragraph is not as useless as it seems. Its purpose is to show you a particular behavior 😊PHP-FFI has a few limitations: you can't pass a PHP variable directly to retrieve its dynamic value from the external library.You only have access to passing C la...
IntroductionSince version 7.4 of PHP, we finally have access to interoperability functions between different languages and PHP: the FFI or Foreign Function Interface.What is FFI? It is simply the ability to use an external library (.dll or .so) directly in PHP, without having to create a PHP extension. Yes, with just a PHP script! It is, among other things, what has made Python so famous and allowed it to have so many features.The great thing about FFI is that a PHP developer who is not an e...