<?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>Thu, 23 May 2013 18:26:53 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Benjamin Eberlei: Doctrine and SOLID]]></title>
      <guid>http://www.phpdeveloper.org/news/19137</guid>
      <link>http://www.phpdeveloper.org/news/19137</link>
      <description><![CDATA[<p>
<i>Benjamin Eberlei</i> has a new post to his site today answering a question he sometimes gets about <a href="http://www.whitewashing.de/2013/02/04/doctrine_and_solid.html">using Doctrine2 in a SOLID context</a> (more on SOLID development <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">here</a>) as it seems difficult to follow the Single Responsibility Principle with how the tool is used.
</p>
<blockquote>
These problems are related to the inability to share behavioral code through aggregation and the complexity of state transformations. Combining both, your average entity with 5-15 fields can end up with hundrets or thousands lines of code. The solutions to both problems boil down to <a href="http://www.jbrains.ca/permalink/the-four-elements-of-simple-design">minimizing duplication and maximizing clarity</a>.
</blockquote>
<p>
He looks at two different kinds of objects Doctrine uses in its setup, the value objects and method objects, and "maximize clarity" on them by dividing them up into more functional-related objects, passed into each other via method injection.
</p>]]></description>
      <pubDate>Tue, 05 Feb 2013 11:09:33 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso: Handling several DBALs in Symfony2 through the Dependency Injection with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19044</guid>
      <link>http://www.phpdeveloper.org/news/19044</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has a second post in his series looking at using the Symfony2 dependency injection container with Doctrine functionality. In his <a href="http://phpdeveloper.org/news/19007">previous post</a> he talked about sharing PDO connections via the DIC. In <a href="http://gonzalo123.com/2013/01/14/handling-several-dbal-database-connections-in-symfony2-through-the-dependency-injection-container-with-php/">this latest one</a> it's focused on the sharing of DBALs from Doctrine.
</p>
<blockquote>
OK. We can handle PDOs connections inside a Symfony2 application, but what happens if we prefer DBAL. As we know DBAL is built over PDO and adds a set of "extra" features to our database connection. It's something like PDO with steroids.
</blockquote>
<p>
He includes the (PHP) configuration to set up the DBAL and the YAML definition to set it up in the DIC's configuration. As an update to the post, he also points out a bundle for Symfony2 that lets Doctrine do this natively - check out <a href="https://github.com/doctrine/DoctrineBundle/blob/master/Resources/doc/configuration.rst#doctrine-dbal-configuration">this documentation</a> on github.
</p>]]></description>
      <pubDate>Wed, 16 Jan 2013 10:47:32 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Michael Nitschinger: Caching Doctrine Entities with Couchbase]]></title>
      <guid>http://www.phpdeveloper.org/news/19006</guid>
      <link>http://www.phpdeveloper.org/news/19006</link>
      <description><![CDATA[<p>
<i>Michael Nitschinger</i> has a new post to his site today showing how you can <a href="http://nitschinger.at/Caching-Doctrine-Entities-with-Couchbase">cache the entities</a> you've created with Doctrine using <a href="http://www.couchbase.com">Couchbase</a> as a simple caching tool.
</p>
<blockquote>
As part of our ongoing efforts to make Couchbase more integrated with frameworks and libraries, we added caching support for the <a href="http://www.doctrine-project.org/">Doctrine ORM</a>. [...] Caching can either be used standalone (through the API provided by <a href="http://www.doctrine-project.org/projects/common.html">doctrine/common</a>) or integrated with the ORM functionality. We'll look at both variants through simple examples, a good documentation can also be found here. Note that at the time of writing, the CouchbaseCache is not mentioned as a caching driver because the documentation still needs to be updated.
</blockquote>
<p>
He walks you through the steps to get everything you need installed, both through Composer and the <a href="http://www.couchbase.com/develop/php/current">Couchbase extension</a> so your PHP installation will support it. He includes sample code that sets up the cache and shows how to check it to see if a key exists. With this base in place, he expands it out to working with the Doctrine ORM. He shows how to create a sample "Person" entity, inject it into the entity manager and perform a query with the Result Cache to locate the object.
</p>]]></description>
      <pubDate>Tue, 08 Jan 2013 10:19:07 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jake Bell: PHP Annotations Are a Horrible Idea]]></title>
      <guid>http://www.phpdeveloper.org/news/18623</guid>
      <link>http://www.phpdeveloper.org/news/18623</link>
      <description><![CDATA[<p>
In his latest post <i>Jake Bell</i> talks about why he thinks <a href="http://theunraveler.com/blog/2012/php-annotations-are-a-horrible-idea/">annotations in PHP are a bad idea</a> (not the concept of them, but how developers are currently using them. He's in favor of <a href="https://wiki.php.net/rfc/annotations">officil support</a> though).
</p>
<blockquote>
Both the Symfony 2 and Doctrine 2 libraries and components make liberal use of what have come to be called annotations - special code comments, usually prefixed with an @ that are actually interpreted by the application and affect its functionality. [...] This trend needs to die.
</blockquote>
<p>
He points out that the use of code comments like this isn't a good practice and applications should never have to rely on them for functionality. He mentions issues with syntax/language functionality (can't use "php -l" on them, can't var_dump an annotation) and that it makes it more difficult to read and interpret the code. He includes an example from Ruby of an alternative and a possible solution in PHP involving a static "mapping" variable.
</p>]]></description>
      <pubDate>Thu, 18 Oct 2012 09:45:56 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeune Asuncion: ZF1.11 + Doctrine 2 + Symfony DI Integration]]></title>
      <guid>http://www.phpdeveloper.org/news/18391</guid>
      <link>http://www.phpdeveloper.org/news/18391</link>
      <description><![CDATA[<p>
In <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/">this new post</a> to his site <i>Jeune Asuncion</i> shows how he integrated several technologies to make for a robust system - Zend Framework (1.11), Doctrine 2 and the Symfony dependency injection system.
</p>
<blockquote>
Last week, <a href="http://jeunito.me/choosing-a-new-framework/">I blogged about looking for a new application framework</a> to use and more importantly the key things that I would want in one. After reading about the <a href="http://framework.zend.com/">Zend framework</a>, <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/www.symfony-project.org/">Symfony</a> and <a href="http://jeunito.me/zf1-11-doctrine-2-symfony-di-integration/laravel.com/">Laravel</a> and finding myself hesitant to use any one, I thought to myself why not get the best of each framework? So that's what I did.
</blockquote>
<p>
He shows a bit of the code to get them to all play nicely together using the Zend autoloader to register the other namespaces and creating a Symfony DI container inside of the ZF Bootstrap and providing it as a resource. You can find more of the source involved in the integration <a href="https://github.com/jeunito/zf-doctrine2-symfonydi">on his github account</a>.
</p>]]></description>
      <pubDate>Wed, 22 Aug 2012 11:09:21 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Till Klampaeckel: Continuous Integration: Automated database setup with Doctrine on Travis-CI]]></title>
      <guid>http://www.phpdeveloper.org/news/18357</guid>
      <link>http://www.phpdeveloper.org/news/18357</link>
      <description><![CDATA[<p>
<i>Till Klampaeckel</i> has a new post to his site showing how you can use the external continuous integration system <a href="http://travis-ci.org/">Travis-CI</a> to handle <a href="http://till.klampaeckel.de/blog/archives/192-Continuous-Integration-Automated-database-setup-with-Doctrine-on-Travis-CI.html">automated database testing</a> for your PHP app using Doctrine.
</p>
<blockquote>
Testing is important - most people understand that by now. A lot of people write tests for their open source code already, but in-house testing is still hard. [...] While I prefer to run my database tests against a SQLite in memory database, there are these edge cases, where I work with multiple database or I write a direct query (and by-pass the ORM-magic). In these cases I need to have that database server available in my test environment! The following blog posts explains how to solve these things with Travis-CI. I will walk you through the setup on Travis-CI's business service. But most of this applies to their open source offering as well.
</blockquote>
<p>
He's broken it up into a few different steps - the setup and configuration of the ".travis.yml" file, adding in a "composer.json" file with the needed dependencies and the recommendation of a "phpunit.xml" in your project's root. He shows how to use Doctrine's "SchemaTool" utility to generate his schema off of the comments on his entities (instead of checking in SQL). This setup them gives him access to Doctrine's EntityManager object in his tests and he can go from there. If you're thinking about doing something similar, check Travis' <a href="http://about.travis-ci.org/docs/user/database-setup/">list of supported databases</a> before you do anything, just to be sure.
</p>]]></description>
      <pubDate>Tue, 14 Aug 2012 10:55:57 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Matthew Weier O'Phinney's Blog: On Visibility in OOP]]></title>
      <guid>http://www.phpdeveloper.org/news/18156</guid>
      <link>http://www.phpdeveloper.org/news/18156</link>
      <description><![CDATA[<p>
<i>Matthew Weier O'Phinney</i> has a new post to his blog today looking at <a href="http://mwop.net/blog/2012-06-28-oop-visibility.html">visibility in OOP in PHP</a> - less about the features the language offers and more about the theory of their use.
</p>
<blockquote>
I'm a big proponent of object oriented programming. OOP done right helps ease code maintenance and enables code re-use. Starting in PHP, OOP enthusiasts got a whole bunch of new tools, and new tools keep coming into the language for us with each minor release. One feature that has had a huge impact on frameworks and libraries has been available since the earliest PHP 5 versions: visibility.
</blockquote>
<p>
He covers a bit of the syntax and features of public, private and protected and mentions a keyword not often seen in PHP applications - <a href="http://us2.php.net/manual/en/language.oop5.final.php">final</a>. The reason all of this came up was work on annotation support in Zend Framework 2 and some difficulty in integrating it with Doctrine support. The "final" status of the class was part of the problem, and after a a lot of copy & pasting he decided on a different tactic - using its public API to try to work around the problem.
</p>
<blockquote>
In sum: because the class in question was marked final and had private members, I found myself forced to think critically about what I wanted to accomplish, and then thoroughly understand the public API to see how I might accomplish that task without the ability to extend.
</blockquote>]]></description>
      <pubDate>Fri, 29 Jun 2012 09:52:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Cook's Blog: Normalising DateTimes with Doctrine Events]]></title>
      <guid>http://www.phpdeveloper.org/news/18147</guid>
      <link>http://www.phpdeveloper.org/news/18147</link>
      <description><![CDATA[<p>
<i>Jeremy Cook</i> has <a href="http://jeremycook.ca/2012/06/24/normalising-datetimes-with-doctrine-events/">written up a new post</a> showing you a method for normalizing the date and time information in your application (DateTime) with the help of Doctrine's own event listeners.
</p>
<blockquote>
The solution we hit on was to leverage <a href="http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#listening-to-lifecycle-events">Doctrine's system of event listeners</a> to help us do the work. Doctrine allows you to register listeners with the entity manager that are called whenever certain events occur. We created an event listener that is triggered on the onFlush event.
</blockquote>
<p>
Code is included for the event listener they created - a simple "onFlush" event that grabs the current entities from the manager, sets the date/time property to allow it to be changed (via Reflection) and updating it with the new cleaned format.
</p>]]></description>
      <pubDate>Wed, 27 Jun 2012 12:44:03 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[GotoTech.com: Developer Diary: Taming Doctrine's 2000 Flushes]]></title>
      <guid>http://www.phpdeveloper.org/news/17897</guid>
      <link>http://www.phpdeveloper.org/news/17897</link>
      <description><![CDATA[<p>
In <a href="http://gototech.com/?p=221">this new post</a> to the GotoTech.com blog <i>Eric Burns</i> talks about a way he's "tamed Doctrine's 2000 flushes" with a wrapper around the EntityManager to make controlling the database flushes simpler.
</p>
<blockquote>
For my project I decided to use the Doctrine 2 ORM to manage my data layer. We also use this at work, so the biggest reason I chose this was to be able to learn more about Doctrine to help me in my job. But this decision also makes sense for my project because my entity relationships will likely be fairly straightforward for the most part and using an ORM will allow me to make a lot of progress very quickly without (I hope) causing me lots of trouble later on.
</blockquote>
<p>
His handy wrapper (Data Manager) makes it simpler to perform the flush and still take transactions into consideration. His simple class includes "flush", "commit" and "startTransaction" methods that don't actually perform the flush until the commit is called.
</p>]]></description>
      <pubDate>Wed, 02 May 2012 10:19:35 -0500</pubDate>
    </item>
    <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>
  </channel>
</rss>
