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 Questions3. Building and Installing a PHP ExtensionThis extension skeleton can be compiled without any changes. The first “phpize” command is a part of the PHP build we created in the first step. (It should still be in the PATH.) $ phpize $ ./configure $ make $ make installThese commands should build our shared extension “test.so” and copy it into appropriate directory of our PHP installation. To load it, we need to add a line into our custom php.ini $ vi ~/php-bin/DEBUG/etc/php.iniAdd the following line:extension=test.so Check that extension is loaded and works. “php -m” command prints the list of loaded extensions: $ php -m | grep test testWe may also run the functions defined in our “test” extension: $ php -r ‘test_test1();’ The extension test is loaded and working! $ php -r ‘echo test_test2(“world\n”);’ Hello worldNow it makes sense to start tracking our source changes using version control system. (I prefer GIT.) $ git init $ git add config.m4 config.w32 test.c php_test.h tests $ git commit -m “Initial Extension Skeleton”Request PDF VersionBook traversal links for 3. Building and Installing a PHP Extension‹ 2. Generating a PHP Extension SkeletonWriting PHP Extensions4. Rebuilding Extensions for Production ›