![Writing PHP Extensions](https://phptek.tv/storage/talk_gifs/C9eDK7hJoYzsbyAzw4YjBUOgHrV7MCjV2k01JCcM003Io.gif)
Level: Advanced
Length: Tutorial (3 hours)
Description:
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.
Required
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)
- GIT clone of the php-src repository (https://github.com/php/php-src.git)