This book descibes PHP extension building using C++. A bunch of C++ wrapper classes manages the PHP standard data structure types, and are used in a large number of PHP class examples, that are part of a web site framework, which has the same extension classes alternatively implemented in PHP Script.

The wrapper classes contain PHP API defined C pointers to zend_string, zend_object, and HashTable, with extensive manipulation access, and lifetime reference count management outside of the standard zval based wrapper.

A wrapper class for zval* and zval structure allows , plus read and write interfaces for calling and handling PHP functions.

An integrated C++ base class integrates with zend_object instances, to implement PHP object classes. Each class example has template static class manager instance for lifetime management. The PHP class object registrations are generated from the PHP provided C code generation of \xxx_arginfo.h files, from its "\xxx_stub.php" parser, so C++ class implementations can be invoked with the same function declarations as script implementations.

The wrapped C pointer types are passed around as "smart pointers". The base types are none-reference counting, for allowing access, and function argument passing, without reference count penalty.

The implemented script and C++ version examples include about 40 classes in the Wcc and Wcd namespaces, which are frequently called in a standard web page request. If in doubt about the data processing flow of the framework, the C++ extension can be disabled to debug execution of the slower PHP coded implementations.

The process of coding the classes is very much the same as the standard tutorial for an extension project in the C languange. The module api registration is helped by <class>_arginfo.h files are automatically generated by the gen_stub.php script. Once the method contents are supplied, a class build and compile is done with the standard recommended phpize, configure, and generated make file sequence. A single module master file can include in all the code for one loadable extension.

The actual class APIs for the web class examples are documented for the PHP script versions, as the goal is to design the script and C++ versions to be very close in call compatibility. It is hoped that the web classes are useful and robust enough for wider use, to spread the benefits of faster implementations in regular usage.

Issues and intented strategy are discussed in futher chapters, with the design of classes used with web request handling.

The contributions of the long evolved PHP-CPP project are appreciated. A recent version of PHP-CPP was gutted and simplified by using wrapper classes from this ZPP-CPP project.

A public repository for the ZPP-CPP classes exists on github.