Skip to main content

Main navigation

  • Solutions
    • Zend Server
    • ZendPHP Enterprise
    • Laminas Enterprise Support
  • Services
    • Services
      • Services Overview
    • Services Links
      • Services Links Row
        • Migrations
        • PHP Long-Term Support
        • Custom Consulting
        • Audits
        • CI/CD
  • Training
    • Training Featured Links
      • Training
      • Training Bundles
      • Help Me Choose
    • Training Links
      • Training Links Row
        • PHP Training
        • Zend Framework Training
        • Zend Server Training
        • PHP Certification
        • Zend Framework Certification
        • Apache Fundamentals
        • IBM i Training Exercises
  • Resources
    • Resources Featured Links
      • Resources
    • Resource Links
      • Resource Links Row
        • Papers & Videos
        • Events & Webinars
        • Recorded Webinars
        • Blog
        • Case Studies
        • PHP Security Center
  • Support
    • Support Featured Links
      • Support
      • Request Support
    • Support Links
      • Support Links Row
        • PHP Long-Term Support
        • Knowledgebase
        • Documentation
        • Download Software
        • Download Plugins
  • Free Trial

Secondary Navigation

  • PHP Security Center
  • Blog
  • Store
  • Downloads
    • Downloads
    • Plugins
    • MyZend Account
  • Company
    • About Zend by Perforce
    • Careers at Perforce
    • Customers
    • Partners
    • Press
  • Contact
    • Contact Us
    • Request Support
    • Subscribe
Created with Avocode.

Secondary Navigation

  • PHP Security Center
  • Blog
  • Store
  • Downloads
    • Downloads
    • Plugins
    • MyZend Account
  • Company
    • About Zend by Perforce
    • Careers at Perforce
    • Customers
    • Partners
    • Press
  • Contact
    • Contact Us
    • Request Support
    • Subscribe
Home
Zend

Main Navigation - Mega Menu

  • Products

    Main Navigation - Mega Menu

    • Zend Server
      PHP Application Server
    • Zend Server Full Stack
      Enterprise Support
    • ZendPHP
      PHP Runtime and Support
    • Laminas Enterprise Support
      Formerly Zend Framework
  • Services

    Main Navigation - Mega Menu

    • Service Overview
    • Migration
    • PHP Long-Term Support
    • Audits
    • CI/CD
    • Custom Consulting

    Services

    Innovate faster and cut risk with PHP experts from Zend Services.

    Explore Services

  • Training

    Main Navigation - Mega Menu

    • Training Overview
    • PHP Training
    • PHP Certification
    • IBM i Training Exercises
    • Apache Fundamentals
    • Zend Server Training
    • Laminas Training
    • Zend Framework Certification
    • Training Bundles

    Training

    Beginning to advanced PHP classes to learn and earn global certification.

    Help me choose >

    Explore Training

  • Resources

    Main Navigation - Mega Menu

    • Explore Resources
    • Events & Webinars
    • Papers & Videos
    • Recorded Webinars
    • Blog
    Cloud Orchestration

    Orchestrating Your PHP Applications

    Watch Now
  • Support

    Main Navigation - Mega Menu

    • Explore Support
    • PHP Long-Term Support
    • Knowledgebase
    • Documentation
    • Download Software
    • Download Plugins
    • Request Support

    Support

    Submit support requests and browse self-service resources.

    Explore Support

  • Try Free
  • PHP Security Center
  • Blog
  • Store
  • Downloads

    Main Navigation - Mega Menu

    • Downloads
    • Plugins
    • MyZend Account
    • Downloads
    • Plugins
    • MyZend Account
  • Company

    Main Navigation - Mega Menu

    • About Zend by Perforce
    • Careers at Perforce
    • Customers
    • Partners
    • Press
    • About Zend by Perforce
    • Careers at Perforce
    • Customers
    • Partners
    • Press
  • Contact

    Main Navigation - Mega Menu

    • Contact Us
    • Request Support
    • Subscribe

TECHNICAL GUIDE

Writing PHP Extensions

Request PDF Version
Writing PHP Extensions
1. Setting up Your PHP Build Environment on Linux
2. Generating a PHP Extension Skeleton
3. Building and Installing a PHP Extension
4. Rebuilding Extensions for Production
5. Extension Skeleton File Content
6. Running PHP Extension Tests
7. Adding New Functionality
8. Basic PHP Structures
9. PHP Arrays
10. Catching Memory Leaks
11. PHP Memory Management
12. PHP References
13. Copy on Write
14. PHP Classes and Objects
15. Using OOP in our Example Extension
16. Embedding C Data into PHP Objects
17. Overriding Object Handlers
18. Answers to Common Extension Questions

Writing PHP Extensions

Knowing how to use and write PHP extensions is a critical PHP development skill that can save significant time and enable you to quickly add new features to your apps. For example, today, there are more than 150 extensions from the PHP community that provide ready-to-go compiled libraries that enable functions. By using them in your apps, you can avoid developing them yourself. 

Despite the large number of existing PHP extensions, you may need to write your own. To help you do that, this document describes how to:

  • Setup a Linux PHP build environment.
  • Generate an extension skeleton.
  • Build and install a PHP extension.
  • Rebuild extensions for production.
  • Understand extension skeleton file content.
  • Run extension tests.
  • Add new functionality (functions, callbacks, constants, global variables, and configuration directives).
  • Use basic PHP structures, including the API.
  • Use PHP arrays.
  • Catch memory leaks.
  • Manage memory.
  • Use PHP references.
  • Use copy on write.
  • Use PHP classes and objects.
  • Use object-oriented programming (OOP) in an extension.
  • Embed C data in PHP objects.
  • Override object handlers.
  • Avoid common issues with external library linking, naming conventions, and PHP resource type.

To help you learn from all the coding examples in this document, please visit the GIT repository, https://github.com/dstogov/php-extension. It includes a copy of all the files generated when creating the sample extension described in this digital book. The extension modifications are reflected by separate GIT commits.

Request PDF Version
  • 1. Setting up Your PHP Build Environment on Linux
  • 2. Generating a PHP Extension Skeleton
  • 3. Building and Installing a PHP Extension
  • 4. Rebuilding Extensions for Production
  • 5. Extension Skeleton File Content
  • 6. Running PHP Extension Tests
  • 7. Adding New Functionality
  • 8. Basic PHP Structures
  • 9. PHP Arrays
  • 10. Catching Memory Leaks
  • 11. PHP Memory Management
  • 12. PHP References
  • 13. Copy on Write
  • 14. PHP Classes and Objects
  • 15. Using OOP in our Example Extension
  • 16. Embedding C Data into PHP Objects
  • 17. Overriding Object Handlers
  • 18. Answers to Common Extension Questions

Book traversal links for Writing PHP Extensions

  • 1. Setting up Your PHP Build Environment on Linux ›

Footer menu

  • Products
    • Zend Server
    • Zend Server Full Stack
    • ZendPHP
    • Laminas Enterprise Support
    • PHP Development Tools
  • Resources
    • PHP Security Center
    • Papers & Videos
    • Events & Webinars
    • Recorded Webinars
    • Blog
    • Case Studies
  • Services
    • PHP Long-Term Support
    • Migrations
    • Audits
    • CI/CD Services
    • Custom Consulting
  • Downloads
    • MyZend Account
    • Plugins
  • Training
    • IBM i Training Exercises
    • PHP Training
    • Laminas Training
    • Zend Server Training
    • PHP Certification
    • Zend Framework Certification
    • Apache Fundamentals
    • Training Bundles
    • Help Me Choose
  • Support
    • PHP Long-term Support
    • Knowledgebase
    • Documentation
  • Store
  • Hubs
    • Developing Web Apps With PHP
    • Guide to PHP and IBM i
    • PHP Migrations Knowledge Base
  • FREE TRIALS
    • Zend Server
    • ZendPHP
  • Company
    • About Zend by Perforce
    • Careers at Perforce
    • Customers
    • Partners
    • Press
  • Contact
    • Request Support
    • Subscribe
Home

Zend by Perforce © 2022 Perforce Software, Inc.
Terms of Use  |  Privacy Policy | Sitemap

Social Menu

  • Facebook
  • LinkedIn
  • Twitter
  • YouTube
  • RSS
Send Feedback