PHP Extensions - dark magic in C
8 June, 2018
Travis Stockwell
travis.stockwell@gmail.com
Things you need to know about me . . .
Objective
Understand the reason(s) for writing an extension (the virtues and the vices), the basic framework to get started.
Resource(s)
Sara Goleman is the monarch of PHP extensions.
Read Embedding & Extending PHP, even though it’s for PHP5.
Motives
PHP internals
Lifecycles
There are two groups of initialization and shutdown:
Memory allocation
Traditional | Non-Persistent | Persistent |
malloc() / calloc() | emalloc() / ecalloc() | pemalloc() / pecalloc() |
strdup() / strndup() | estrdup() / estrndup() | pestrdup() / pestrndup() |
free() | efree() | pefree() |
realloc() | erealloc() | perealloc() |
You’ll need some stuff . . .
Grab an existing extension and hack
Let’s write some code
Exercises for the student