On 20 May 2011 17:15, Larry Garfield <la...@garfieldtech.com> wrote: > Hi all. > > I'm working with a fellow developer on an experimental project. There are > some PECL modules that we want to try and use in an open source project > where we cannot guarantee that PECL modules will be available, since it's > intended for widespread distribution on both shared hosts and custom > hosting. The thought we had was to do a user-space port of the PECL module > to include in the project and rely on that. Then if the PECL module is > installed, we don't include the library (either via an extension_loaded() > check or just relying on autoload) and the PECL implementation gets used > instead. Poof, nice speed boost. > > The questions I have are: > > 1) Is this even a viable approach? It seems like it, but to my knowledge no > one else has done this to any serious extent which makes me wonder if > there's a reason the road less traveled is less traveled. > > 2) Is anyone else doing this? No sense doing it ourselves if someone else > already is. > > 3) What would be the cleanest way to do so? We had the thought of partially > automating the process by having PHP auto-generate at the very least the > subs of any classes and functions that the module provides. However, when > my colleague tried using the same parser as is used for generating > documentation he says he got several times as many classes as the manual > says the module has. We were using the PECL HTTP module as our sample > (http://www.php.net/http). (I don't know the exact details of what he did > at the moment.) Is that not a viable approach? Would we be better off > using reflection? Is there some other tool we're not aware of? > > If viable I'd love if this would start a trend, but we'll see where it goes. > I know it wouldn't work for all PECL modules, obviously, but I suspect it > could work for several, and provide an easy way for different PHP projects > to share backend code without needing lots of C developers. > > --Larry Garfield
If you using an extension that exists as glue to a third party library, then you are going to need PHP to communicate at a very low level. Something I'm not sure would be possible at the moment. If the extension is self contained, then this would more likely be a good candidate. You can use reflection to build the stubs easily enough But I'm not sure all the things you can do in C can be done in PHP, not without a LOT of effort. Talking to third party libraries or making c calls to the OS is out. Richard. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php