Been reading Jacob's blog for a while now, really interested in the gaming library work going on and one of the things that came up was making an extension to accelerator the gaming library.
Its been a while since I last played around with extensions, not since php4 so I scanned through the manual and some only tutorials and threw together this quick and dirty guide to help you get started, again quick and dirty, not a hand holding ends all guide to making an extension, if you don't know some C and php already this is not for you.
I was gratefull to find out that php5 still has a nifty little utility called ext_skel which does a large part of the work for you, making the best use of this utility just requires a little planning ahead of time.
Up until now, you've worked with concepts that are familiar and map easily to userspace analogies. In this tutorial, you'll dig into the inner workings of a more alien data type - completely opaque in userspace, but with behavior that should ultimately inspire a sense of déjà vu.
In Part One of this series you looked at the basic framework of a PHP extension. You declared simple functions that returned both static and dynamic values to the calling script, defined INI options, and declared internal values (globals). In this tutorial, you'll learn how to accept values passed into your functions from a calling script and discover how PHP and the Zend Engine manage variables internally.
This document is part two of a series on the internals of PHP. Here we will explore how PHP variables are stored internally, how PHP's typing system works, and the basics of how PHP interacts with it's execution environment
This document is part one of a series on the internals of PHP. Here we will explore how a PHP script is executed, some of the higher level zend engine functionality, and how to use some tools to further your understanding of how PHP works.
If you're reading this tutorial, you probably have some interest in writing an extension for the PHP language. If not... well perhaps when we're done you'll have discovered an interest you didn't know existed!
This tutorial assumes basic familiarity with both the PHP language and the language the PHP interpreter is written in: C.
Let's start by identifying why you might want to write a PHP extension.
1. There is some library or OS specific call which cannot be made from PHP directly because of the degree of abstraction inherent in the language.
2. You want to make PHP itself behave in some unusual way.
3. You've already got some PHP code written, but you know it could be faster, smaller, and consume less memory while running.
4. You have a particularly clever bit of code you want to sell, and it's important that the party you sell it to be able to execute it, but not view the source.
These are all perfectly valid reasons, but in order to create an extension, you need to understand what an extension is first.








