On Mon, May 23, 2011 at 5:14 PM, Daevid Vincent <daevid@xxxxxxxxxx> wrote: >> -----Original Message----- >> From: Eric Butera [mailto:eric.butera@xxxxxxxxx] >> Sent: Friday, May 20, 2011 2:25 PM >> To: PHP >> Subject: Re: observer pattern >> >> [whoops didn't hit reply-all] >> >> On Wed, May 18, 2011 at 5:18 AM, Ken Guest <ken@xxxxxxxx> wrote: >> > Lo, >> > >> > so, I'm wondering - how many of you use the observer pattern in php; >> > and if so, do you implement it 'standalone' or with the spl classes? >> > Is there any particular advantage to doing it "your way"; whichever >> > your way is? >> > >> > Ken >> > >> > -- >> > http://blogs.linux.ie/kenguest/ >> > >> > -- >> > PHP General Mailing List (http://www.php.net/) >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> >> I use it quite a bit over the various projects I maintain. ÂIt allows >> subjects to trigger events that observers can process if they're >> interested, or better yet, completely ignore. ÂThis allows >> standardized code bases to create nice hooks that allow extensibility >> without needing to place one-off code inside the main project. >> >> A quick example might be on saving a record in your code, it triggers >> an event, then an observer in a custom site watches for said event and >> injects/updates a search entry in Lucene. ÂThis way one site can have >> a custom search engine that another site might not need. >> >> I started off with the concepts I found in >> http://examples.stubbles.net/docroot/events/ but created my own >> because I wanted something stand-alone. > > Well, you (or in this case, *I*) learn something new every day. > > I had no idea PHP could do observers. How very "Java" (and neat!) > Granted, it is just a design pattern, but to have the SplObserver stuff built in is pretty cool. > What version of PHP is this available from? The web page doesn't say. > > http://www.labelmedia.co.uk/blog/posts/php-design-patterns-observer-pattern.html > http://cormacscode.wordpress.com/2010/10/12/practical-example-php-implementation-of-the-observer-pattern/ > http://www.php.net/manual/en/book.spl.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Hi Daevid, According to http://us3.php.net/manual/en/splobserver.update.php, (PHP 5 >= 5.1.0) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php