Re: zend_API.c - missing zend_update_property_resource

From: Date: Fri, 06 Jun 2014 07:10:08 +0000
Subject: Re: zend_API.c - missing zend_update_property_resource
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-74773@lists.php.net to get a copy of this message
Hi! On 6 June 2014 00:26, Johannes Schlüter <johannes@schlueters.de> wrote: > On Thu, 2014-06-05 at 21:21 +0200, Nicolai Scheer wrote: [...] > >> > * Usage of resources is discouraged, instead of a resource use an >> > object (extend zend_object to store pointers etc.) >> Didn't know that usage of resources was discouraged... Nearly all my >> knowledge comes from Sara's great book (btw. if you read this Sara, I'd >> love to see and buy a refreshed version!) and my own field tests. >> When you say "use an object", do you refer to the way described in [1]? >> From what I've read so far, this way sounds more complex than just >> registering a resource. >> Could you elaborate a bit on the rationale behind this recommendation? > > They are (incomplete list) > > * slower than objects for many operations > * have an api with some weird behavior (some operations give > errors which are hard to catch as extension author) > * any people consider OO APIs nicer > * resources can't be introspected by PHP level debuggers, var_dump > etc. whereas objects can provide required hooks I see. In fact I use an OO API, ist's just that the object internally stores a connection resource (i.e. a struct containing stuff I need) in a private property. The first version of the extension was not OO, so it seemed straight forward just to wrap the connection resource within a class, so that you don't need to pass it around in userspace all the time. Extending zend_object to store my data structures sounds as the next I should take to further "objectify" my extension. Thanks for the pointers! Greetings Nico

« previous php.internals (#74773) next »