While PHP core comes with some nice functionality, the real power in PHP is found in extensions. Some of the functionality we take for granted come from extensions that are always enabled (e.g. the "standard" extension provides output buffering, array functions like sort() and in_array(), string utilities like trim() and explode(), and more). While plenty of extensions are bundled with PHP, and either always enabled (like reflection and json) or can be enabled with build flags (like mbstring and zip), extensions can also be written separately. Third-party extensions include APCu, ImageMagick, Yaml and more.

In this tutorial, we will cover how to create your own PHP extension. Initial topics include zvals, zend strings, hash tables, parameter parsing, and engine hooks. Hands-on examples will cover global functions, class registration, opaque types managed outside of the property system, and the use of external libraries.

Extensions have been written in C, C++, Rust, and probably other languages too. This tutorial will be conduct in Rust, but knowledge of C will help with understanding the use of the PHP ABI.

Comments

Comments are closed.