News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ivo Jansch's Blog:
Mixins in PHP
August 25, 2006 @ 08:02:33

In his latest post today, Ivo Jansch talks about a concpt from Ruby that he likes and wanted to try to implment in PHP - mixins.

Mixins are a way of 'mixing in' functionality of other classes. A kind of 'multiple inheritance' like approach, only without actual inheritance. It is similar to interfaces, but interfaces only tell you that an object must implement certain methods, whereas mixins also provide an implementation.

To help clear it up a bit he links to two articles on the topic. He gives some examples, though, of how it all works by creating a mixin class (Alertable) and the wy to apply it (in the Hello class). The key between the two is the Object class he's created. It allows the two other classes to work with each other without the need for cumbersome includes or passing around objects. All methods are magically available to the Hello object.

Of course, it's not a perfect implementation because PHP just can't do some things, but he includes a few of these things to watch out for in using this method.

0 comments voice your opinion now!
mixin ruby php5 class alert multiple inheritance mixin ruby php5 class alert multiple inheritance


blog comments powered by Disqus

Similar Posts

DevShed: Paginating Result Sets for a Search Engine Built with MySQL and PHP 5

Greg Beaver's Blog: PHP_ParserGenerator and PHP_LexerGenerator

Job Posting: Open Source Staffing Seeks a PHP5 Developer (New York, NY)

Aaron Wormus' Blog: WS02 at Zend Conf

Ilia Alshanetsky's Blog: 5.2.2RC1 Released for Testing


Community Events





Don't see your event here?
Let us know!


podcast bugfix laravel voicesoftheelephpant opinion tips series introduction package interview list install release api symfony community language library deployment framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework