Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52484 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95232 invoked from network); 20 May 2011 16:35:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 May 2011 16:35:00 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:39929] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BD/13-12578-33896DD4 for ; Fri, 20 May 2011 12:35:00 -0400 Received: by qyk32 with SMTP id 32so431764qyk.8 for ; Fri, 20 May 2011 09:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=bMoRjkCa3kol7ftYzafAIu5yblMUmH/S9P7fLaoyY3c=; b=XFVVWoWHfOssPETyQAH6Ibq1HBOrdsO2wWUt4p+eVqmooa3a0TRRbnq20u2kjzKsF+ pkXsB46/nM831UsgEXaPNV/ySlbK2xSsaF5MxcFM4YAS+gJD6QR9MkKEIuYC/44pczXB rgS+/IXb7aMsFddvgh0pidpkg0yGoL0bzxrgc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=qYjkFnInzza3gVphWAyt+Eg2Rtp2HwKvwp36SyGxeTy22xjUQTYvLdT3mNa1ZFpOGw gNOP/fLAupev5vCIkigYRSqgUxOG/fE1zKfbCraNhv+HT35KVVecNYTDAAWJCWf3moPG nqPJluX1Fsj8oC9SuFzN3m/3zlvVrTKYmYNpE= Received: by 10.229.13.152 with SMTP id c24mr3495371qca.87.1305909297109; Fri, 20 May 2011 09:34:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.85.137 with HTTP; Fri, 20 May 2011 09:34:37 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: <4DD693BB.7030300@garfieldtech.com> References: <4DD693BB.7030300@garfieldtech.com> Date: Fri, 20 May 2011 17:34:37 +0100 Message-ID: To: Larry Garfield Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Porting PECL to userspace From: rquadling@gmail.com (Richard Quadling) On 20 May 2011 17:15, Larry Garfield wrote: > Hi all. > > I'm working with a fellow developer on an experimental project. =C2=A0The= re 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 modul= e > to include in the project and rely on that. =C2=A0Then 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. =C2=A0Poof, nice speed boost. > > The questions I have are: > > 1) Is this even a viable approach? =C2=A0It seems like it, but to my know= ledge 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? =C2=A0No sense doing it ourselves if someon= e else > already is. > > 3) What would be the cleanest way to do so? =C2=A0We had the thought of p= artially > automating the process by having PHP auto-generate at the very least the > subs of any classes and functions that the module provides. =C2=A0However= , 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. =C2=A0We were using the PECL HTTP module as our samp= le > (http://www.php.net/http). =C2=A0(I don't know the exact details of what = he did > at the moment.) =C2=A0Is that not a viable approach? =C2=A0Would we be be= tter off > using reflection? =C2=A0Is 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 go= es. > =C2=A0I know it wouldn't work for all PECL modules, obviously, but I susp= ect it > could work for several, and provide an easy way for different PHP project= s > 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. --=20 Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea