Writing PHP Extensions
In this workshop, you will learn how to write a PHP extension.
We will start by converting a function that we already have in PHP code into C, which we will then wrap in a PHP extension. This will show what performance benefits you can expect by converting an algorithm.
Secondly, we will then look at wrapping the data structure that the function operates on into a class, with the initial function converted to a method. And then lastly we will add multiple methods to finish up.
What You Will Learn
– How PHP’s build system works.
– How PHP handlers memory management and types.
– How to write a basic extension with procedural functions and OO.
– Where extensions would not be useful.
For understanding the tutorial:
– Some knowledge of C
For taking part in the exercises:
– A Linux machine or Linux VM
– Compilers installed (apt-get install php-dev, or similar)
– GIT, valgrind, and gdb installed (all through apt, or similar)