conference logo

Playlist "FrOSCon 2012"

PHP Extension Development with C++

Florian Sowade

Since the PHP core and the extension API are implemented in C, most
PHP extensions are written in C, too. But it is possible to write
extensions using the C API and a C++ compiler. This has the advantage
that you can use all the nice features of C++, like object
orientation, exceptions, templates and the STL. Apart from using these
features in the extension code, they can also be used to wrap parts of
the PHP extension API, to provide a cleaner interface.

I will show what such a wrapper could look like, by starting with a
regular C style PHP extension which gets extended using C++ features
and small wrappers. This results in an extension which is easier to
write.