<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Wed, 23 May 2012 11:50:11 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Liip Blog: Table Inheritance with Doctrine]]></title>
      <guid>http://www.phpdeveloper.org/news/17742</guid>
      <link>http://www.phpdeveloper.org/news/17742</link>
      <description><![CDATA[<p>
On the Liip blog there's a recent post looking at <a href="http://blog.liip.ch/archive/2012/03/27/table-inheritance-with-doctrine.html">table inheritance with Doctrine</a>, the popular <a href="http://www.doctrine-project.org/">PHP ORM tool</a>. In the post, <i>Daniel Barsotti</i> talks about a database model that needed some updating due to their searching needs.
</p>
<blockquote>
Our first idea, and it was not that bad, Drupal does just the same, was to have a database table with the common fields, a field containing the type of item (it's either an event or a blog post) and a data field where we serialized the corresponding PHP object. This approach was ok until we had to filter or search LabLog items based on fields that were contained in the serialized data.
</blockquote>
<p>
To resolve the issue they turned to multiple table inheritance, relating the LabLogItem to both a BlogPost and Event. They also show how it could be modeled with a single table, but opt for the multiple method. Included in the post is the Doctrine-based code showing how to create the parent entity for the LabLogItem and the two child entities for the blog post and event. There's also a brief snippet showing how to use them with the EntityManager. 
</p>]]></description>
      <pubDate>Wed, 28 Mar 2012 09:30:09 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using Traits in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17522</guid>
      <link>http://www.phpdeveloper.org/news/17522</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new tutorial about using a feature in the upcoming PHP release (5.4) to make it easier to work with more modular code - <a href="http://phpmaster.com/using-traits-in-php-5-4/">using traits</a>.
</p>
<blockquote>
In this article I will discuss traits, a new feature introduced in PHP 5.4 to overcome [issues where multiple inheritance is needed]. The concept of traits itself is nothing new to programming and is used in other languages like Scala and Perl. They allows us to horizontally reuse code across independent classes in different class hierarchies.
</blockquote>
<p>
Included in the post is example code showing what the use of a trait looks like and a method for creating a Singleton that can spawn instances of two classes. Also included are examples of:
</p>
<ul>
<li>using multiple traits at once, 
<li>traits made up of traits, 
<li>the importance of order, 
<li>aliasing to avoid conflicts, 
<li>reflection 
<li>and a few other features that come along with their use.
</ul>]]></description>
      <pubDate>Thu, 09 Feb 2012 08:40:50 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Elated.com: Object-Oriented PHP: Working with Inheritance]]></title>
      <guid>http://www.phpdeveloper.org/news/16391</guid>
      <link>http://www.phpdeveloper.org/news/16391</link>
      <description><![CDATA[<p>
On Elated.com there's a new <a href="http://www.elated.com/articles/object-oriented-php-working-with-inheritance/">introduction to working with inheritance in PHP</a> for object-oriented applications. They work through some of the basic concepts including parent/child classes, final and abstract classes and interfaces.
</p> 
<blockquote>
In this article we're going to explore the idea of inheritance in object-oriented programming, and how inheritance works in PHP. With inheritance, your objects and classes can become much more powerful and flexible, and you can save a lot of time and effort with your coding.
</blockquote>
<p>
They start with the basics of how inheritance works and then move right into creating child classes from a parent. Their example code makes a basic forum system (just example code, not fully functioning) with administrators, members and forum creation. They use this as a base to show the method overriding and exposure with "final". The finish it off with examples of two things that can promote good application structure - abstract classes an interfaces.
</p>]]></description>
      <pubDate>Fri, 27 May 2011 09:21:20 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Creating Web Page Templates with PHP and Twig (part 2)]]></title>
      <guid>http://www.phpdeveloper.org/news/16302</guid>
      <link>http://www.phpdeveloper.org/news/16302</link>
      <description><![CDATA[<p>
On the Zend Developer Zone they've posted the <a href="http://devzone.zend.com/article/14158-Creating-Web-Page-Templates-with-PHP-and-Twig-part-2">second part</a> of <i>Vikram Vaswani</i>'s look at using the <a href="http://twig-project.org">Twig</a> templating engine in your PHP applications. In the first part of the series, he introduced the tool and got started with some simple examples. In this second part, he dives in deeper to some of the advanced features.
</p>
<blockquote>
In this second and concluding segment, I'll look at some of Twig's other features, including such goodies as template inheritance, custom filters and caching. If you enjoyed the first part of this article, keep reading to find out more about what goes on under Twig's hood, and how you can add even more power and flexibility to your templates
</blockquote>
<p>
He looks at template inheritance, parent blocks/child templates, data filtering, the tool's "compilation cache" and working with native plugins.
</p>]]></description>
      <pubDate>Thu, 05 May 2011 13:11:25 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Bence Eros' Blog: Using Inheritance]]></title>
      <guid>http://www.phpdeveloper.org/news/15529</guid>
      <link>http://www.phpdeveloper.org/news/15529</link>
      <description><![CDATA[<p>
In <a href="http://erosbence.blogspot.com/2010/11/using-inheritance.html">this new post</a> to his blog, <i>Bence</i> looks at how inheritance is commonly used in PHP applications and how, if not controlled carefully can be something that creates bad habits among PHP developers.
</p>
<blockquote>
In fact I think that using inheritance all the time is a very big mistake and makes your code hard to maintain and more hard to integrate (the latter is a mistake for application codes and a fatal mistake for libraries). The main problem with inheritance is that if you use it for coupling two classes, then a very important property of the subclass is used up: it's superclass. It is taken, reserved, and it can not be used for anything else furthermore. If you want to connect your subclass to an other class using inheritance, you can't.
</blockquote>
<p>
He recommends avoiding the typical uses of typical superclass/subclass inheritance unless what you're doing specifically requires it. Working with interfaces, abstract classes and good composition planning is a much better idea.
</p>]]></description>
      <pubDate>Thu, 02 Dec 2010 12:14:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[SimasToleikis' Blog: New to PHP 5.4: Traits]]></title>
      <guid>http://www.phpdeveloper.org/news/15468</guid>
      <link>http://www.phpdeveloper.org/news/15468</link>
      <description><![CDATA[<p>
<i>Simas Toleikis</i> has a new post to his blog looking at a feature that'll be included in PHP 5.4 - something developers have been wanting for a long time - <a href="http://simas.posterous.com/new-to-php-54-traits">traits</a>.
</p>
<blockquote>
As a long-time <a href="http://news.php.net/php.internals">internals.php</a> mailing list reader I am going to tell you a small secret - the first alpha release for PHP 5.4 should be just around the corner. This release is packed with some welcome new language features, usual bug fixes followed by some performance and memory management improvements. One of the noteworthy language additions are Traits - a brand new horizontal code reuse mechanism.
</blockquote>
<p>
He explains traits as a better way to do the "kind-of" inheritance that PHP does now with parent and child classes, making it easier to reuse functionality from classes even though they don't share the same parent. With the "use" keyword (not to be confused with the "use" keyword in namespaces) you can include common functionality into class methods and even accommodate for naming conflicts and requirements.
</p>]]></description>
      <pubDate>Mon, 22 Nov 2010 09:11:09 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Chance Garcia's Blog: Visibility and inheritance]]></title>
      <guid>http://www.phpdeveloper.org/news/13031</guid>
      <link>http://www.phpdeveloper.org/news/13031</link>
      <description><![CDATA[<p>
In <a href="http://phpprotip.com/2009/08/visibility-and-inheritance/">this recent post</a> to his blog <i>Chance Garcia</i> looks at visibility and inheritance in PHP applications. Specifically, it references a question that came up on IRC about the "default" visibility for methods and the <a href="http://en.wikipedia.org/wiki/Open/closed_principle">open/closed principle</a>.
</p>
<blockquote>
Out of the whole discussion, here is the points I got (aka understood) out of it. Please correct me in the comments if I'm off base in any way.
</blockquote>
<p>There's two points he makes in the remainder of the post:</p>
<ul>
<li>Methods should only be public when necessary.
<li>Private methods allow you to preserve the class' core functionality.
</ul>
<p>
There's also a bit of code included to illustrate some of his points.
</p>]]></description>
      <pubDate>Wed, 12 Aug 2009 09:40:20 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage's Blog: Where Multiple Inheritance Will Kill You]]></title>
      <guid>http://www.phpdeveloper.org/news/12896</guid>
      <link>http://www.phpdeveloper.org/news/12896</link>
      <description><![CDATA[<p>
In <a href="http://www.brandonsavage.net/where-multiple-inheritance-will-kill-you/">this new post</a> to his blog <i>Brandon Savage</i> takes a look at multiple inheritance in PHP applications - specifically where it could "kill you" if you're not careful.
</p>
<blockquote>
This is a fantastic way to further encapsulate and abstract your code because it means you can define some base functionality and then later on extend that class to add new functionality and even override existing functionality to make the class specific. But this concept is a double-edged sword in PHP (and all other languages).
</blockquote>
<p>
The problem lies in methods in classes that could be overriding parents and the sort of results that instance of might return in a multiple inheritance environment. He includes code snippets both illustrating the problem and showing a suggestion for how it could be avoided.
</p>]]></description>
      <pubDate>Fri, 17 Jul 2009 11:19:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Blue Parabola Blog: Objectively Oriented]]></title>
      <guid>http://www.phpdeveloper.org/news/11971</guid>
      <link>http://www.phpdeveloper.org/news/11971</link>
      <description><![CDATA[<p>
On the Blue Parabola blog, <i>Matthew Turland</i> <a href="http://blueparabola.com/blog/objectively-oriented">takes a look</a> at object-oriented programming and what core concepts lie at its heart.
</p>
<blockquote>
What is <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programming</a>? The acronym OOP has become a bit of a buzzword in the <a href="http://en.wikipedia.org/wiki/History_of_programming_languages#The_1990s:_the_Internet_age">current age of programming</a>, to the point where the waters of its definition have become rather murky. [...] PHP <a href="http://michaelkimsal.com/blog/php-is-not-object-oriented/">may not be object-oriented</a>, but from a purist perspective, neither is Java. What do I mean by "purist perspective?" Plain and simple: everything is either an <a href="http://en.wikipedia.org/wiki/Object_(computing)#Objects_in_object-oriented_programming">object</a> or a <a href="http://en.wikipedia.org/wiki/Message_passing">message</a> being passed between objects (where message parameters are also objects). 
</blockquote>
<p>
He mentions one of the first languages to support objects (<a href="http://en.wikipedia.org/wiki/Simula">Simula</a>) and the four fundamental concepts that would make a language truly OOP - abstraction, inheritance, encapsulation, polymorphism. Its his opinion, though, that while its good for languages to adhere to these four principles as much as they can, discussions about how well they adhere to them is usually just "spinning your wheels" and don't have much use.
</p>]]></description>
      <pubDate>Wed, 18 Feb 2009 09:31:30 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPImpact Blog: A Django template language clone for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/10925</guid>
      <link>http://www.phpdeveloper.org/news/10925</link>
      <description><![CDATA[<p>
On the PHP::Impact blog today <i>Federico</i> <a href="http://phpimpact.wordpress.com/2008/08/28/calypso-a-django-template-language-clone-for-php/">points out</a> a Django templating language clone for PHP - <a href="http://www.beberlei.de/calypso/">Calypso</a>.
</p>
<blockquote>
Calypso is a full clone of the <a href="http://www.djangoproject.com/documentation/templates/">Django Template Language</a> that helps developers separates the presentational and logic concerns of the application. It offers <a href="http://www.djangoproject.com/documentation/templates/#template-inheritance">template inheritance</a>, pluggable tags and filters, and can be easily integrated into the Zend Framework
</blockquote>
<p>
The most powerful part of the Calypso system is the template inheritance. It allows you to build up a skeleton of templates that can be used for the entire site with blocks and areas that any other part of the application can easily override.
</p>]]></description>
      <pubDate>Fri, 29 Aug 2008 10:25:55 -0500</pubDate>
    </item>
  </channel>
</rss>

