Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop C extensions for PHP apps?

My PHP app has a number-crunching part that is just to slow for PHP, so I was thinking of building a custom C extension, but it is impossible to find any good reference to start with :(

Is there a guide on how to do something like this?

like image 281
Raul Singahn Avatar asked Dec 03 '25 17:12

Raul Singahn


1 Answers

The best resource, although outdated in several aspects (it only covers PHP until version 5.1) is Extending and Embedding PHP by Sara Golemon. Even more outdated is the PHP documentation. On the other hand, the content on the PHP wiki is very up-to-date, but also quite incomplete and not very oriented for beginners. See also these articles, part V of Advanced PHP Programming by George Schlossnagle, chapter 14 of Programming PHP by Rasmus Lerdorf and Kevin Tatroe and, specially, these slides.

Finally, the most authoritative source you'll find is the source code of the extensions bundled with PHP.

like image 177
Artefacto Avatar answered Dec 06 '25 08:12

Artefacto