Writing PHP Extensions1. Setting up Your PHP Build Environment on Linux2. Generating a PHP Extension Skeleton3. Building and Installing a PHP Extension4. Rebuilding Extensions for Production5. Extension Skeleton File Content6. Running PHP Extension Tests7. Adding New Functionality8. Basic PHP Structures9. PHP Arrays10. Catching Memory Leaks11. PHP Memory Management12. PHP References13. Copy on Write14. PHP Classes and Objects15. Using OOP in our Example Extension16. Embedding C Data into PHP Objects17. Overriding Object Handlers18. Answers to Common Extension Questions2. Generating a PHP Extension SkeletonWriting a basic PHP extension is not too difficult. You only need to create a few files. You can do this manually, but you may also use the “ext_skel.php” script:$ php php-src/ext/ext_skel.php --ext test --dir .Unfortunately, this script is not distributed with binary PHP builds and is only available in source distribution. This will create directory “test” with extension skeleton files. Let’s look inside: $ cd test$ ls config.m4 config.w32 php_test.h test.c testsIn the above code snippet: config.m4 is an extension configuration script used by “phpize” or “buildconf” to add extension configuration options into the “configure” command. config.w32 is a similar configuration file for the Windows build system, which is discussed later in this blog. php_test.h is a C header file that contains our common extension definitions. It’s not necessary for simple extensions with a single-source C file, but it’s useful in case the implementation is spread among few files. test.c is the main extension implementation source. It defines all the structures that allow to plug the extension into PHP and make all their internal functions, classes and constants to be available. tests refers to the directory with PHP tests. We will review them later.Request PDF VersionBook traversal links for 2. Generating a PHP Extension Skeleton‹ 1. Setting up Your PHP Build Environment on LinuxWriting PHP Extensions3. Building and Installing a PHP Extension ›