<?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, 24 May 2012 03:57:51 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Lee Davis' Blog: In ORM's Defense]]></title>
      <guid>http://www.phpdeveloper.org/news/17821</guid>
      <link>http://www.phpdeveloper.org/news/17821</link>
      <description><![CDATA[<p>
<i>Lee Davis</i> has a recent post that tries to combat some of the most common excuses people give for not using an ORM rather than opting to write the queries themselves. He <a href="http://www.duckheads.co.uk/in-orms-defence/">writes in defense</a> of the ORM and gives reasons why some of these common complaints may not matter that much.
</p>
<blockquote>
For some reason, as of late, I can't seem to attend any user group or conference without a speaker slating ORM's. Several speakers at the PHP UK Conference this year expressed their disapproval, as well as the speaker at this months PHP London talk. However, no one is giving me a strong enough argument to not use an ORM. Remarks such as "That's a whole other talk" or "Don't get me started on ORM's" seem to be thrown about. But whenever I get a chance to talk about any concerns or issues they're having the conversation just seems to deflate. Am I missing something really terrible about ORM's that's going to creep up and bite me?
</blockquote>
<p>
He goes through and lists some of the most common and explains how, once you get past some of the initial impressions, they might not be so bad:
</p>
<ul>
<li>Using ORMs means having a one to one relation between object and table
<li>ORMs produce sub-optimal SQL and far too many queries
<li>Using ORMs means using active record
<li>ORM is slower than just using SQL, Unlike other abstraction layers, which make up for their performance hit with faster development, ORM layers add almost nothing.
<li>But just pulling out arrays are quicker
<li>Incorrect abstraction - if you don't need relational data features you're using the wrong data store
</ul>]]></description>
      <pubDate>Mon, 16 Apr 2012 11:58:29 -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>
    <item>
      <title><![CDATA[DZone.com: PHP objects in MongoDB with Doctrine]]></title>
      <guid>http://www.phpdeveloper.org/news/17705</guid>
      <link>http://www.phpdeveloper.org/news/17705</link>
      <description><![CDATA[<p>
On DZone.com today <i>Giorgio Sironi</i> has a new post showing how you can <a href="http://css.dzone.com/articles/php-objects-mongodb-doctrine">use Doctrine with MongoDB</a> to work with Document objects from the database.
</p>
<blockquote>
In the PHP world, probably the Doctrine ODM for MongoDB is the most successful. This followes to the opularity of Mongo, which is a transitional product between SQL and NoSQL, still based on some relational concepts like queries. [...] The case for an ODM over a plain Mongo connection object is easy to make: you will still be able to use objects with proper encapsulation (like private fields and associations) and behavior (many methods) instead of extracting just a JSON package from your database.
</blockquote>
<p>
He briefly mentions that the PECL extension for Mongo needs to be installed prior to trying out any of the examples. His first example shows how to create a DocumentManager (similar to the normal EntityManager for those familiar with Doctrine). He also shows an integration with the ORM and shares some of the findings he's made when it comes to versioning the resources (hint: annotations are your friend).
</p>
]]></description>
      <pubDate>Wed, 21 Mar 2012 10:03:59 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Jeremy Cook's Blog: Making PHPUnit, Doctrine & MySQL Play Nicely]]></title>
      <guid>http://www.phpdeveloper.org/news/17620</guid>
      <link>http://www.phpdeveloper.org/news/17620</link>
      <description><![CDATA[<p>
<i>Jeremy Cook</i> has put together a new post showing how he got <a href="http://jeremycook.ca/2012/02/27/making-phpunit-doctrine-mysql-play-nicely/">PUPUnit, Doctrine and MySQL to "play nicely" together</a> when he was writing up some of his tests in a current application.
</p>
<blockquote>
One of the pain points for me though has been in getting Doctrine setup with PHPUnit for testing. One of the main Doctrine contributors, Benjamin Beberlei, has written a package called <a href="https://github.com/beberlei/DoctrineExtensions">DoctrineExtensions</a> which amongst other things adds a class called DoctrineExtensionsPHPUnitOrmTestCase which extends PHPUnit's DbUnit database test case class. This all works well in principle but hits a major snag in reality: MySQL doesn't allow InnoDb tables with foreign keys to be truncated. PHUnit's database extension truncates the database tables before each test run and inserts a fresh set of data to work with.
</blockquote>
<p>
To work around this issue <i>Jeremy</i> by porting over <a href="https://gist.github.com/1319731">a method</a> posted by <i>Mike Lively</i> over to Doctrine as a custom "MySQLTruncate" class (code included in the post). He also includes some sample code showing it in use - a basic ORM test case that calls the truncate method when its set up. 
</p>]]></description>
      <pubDate>Fri, 02 Mar 2012 12:05:48 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Marcelo Gornstein's Blog: Writing PHP applications with Doctrine2 as ORM and Ding as DI container]]></title>
      <guid>http://www.phpdeveloper.org/news/17469</guid>
      <link>http://www.phpdeveloper.org/news/17469</link>
      <description><![CDATA[<p>
In a recent post <i>Marcelo Gornstein</i> takes a look at <a href="http://marcelog.github.com/articles/php_applications_with_doctrine2_orm_and_ding_di_container.html">using dependency injection with Doctrine2</a> using his <a href="http://marcelog.github.com/Ding">Ding</a> container.
</p>
<blockquote>
This article will show how we can develop software in php with a nifty design and architecture, and very much like other languages like java, using an ORM and an AOP, DI, Events container. I will assume you've read (or at least took a quick look) at <a href="http://marcelog.github.com/articles/creating_php_cli_standalone_portable_applications_with_pear_dependencies.html">this article</a> that explains the tree layout used throughout the code, and that you have some basic knowledge of <a href="http://www.doctrine-project.org/">Doctrine2</a> and used it before on your own.
</blockquote>
<p>
He starts with the result - an easy to use, self-contained (and decoupled) system for accessing the Doctrine2 instance. It's event-driven and uses <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Aspect-oriented programming</a> to mange interactions between components (or as he calls them "beans"). Code is included for the entire process for a logger, the User entity, entity manager, user repository and transactional aspect. You can find the complete source for his example <a href="https://github.com/marcelog/Doctrine2-Ding-Example">on his github account</a>.
</p>]]></description>
      <pubDate>Tue, 31 Jan 2012 08:59:18 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Devshed: Building a PHP ORM: Deploying a Blog]]></title>
      <guid>http://www.phpdeveloper.org/news/17237</guid>
      <link>http://www.phpdeveloper.org/news/17237</link>
      <description><![CDATA[<p>
DevShed concludes their three-part series about building an ORM in PHP with <a href="http://www.devshed.com/c/a/MySQL/Building-a-PHP-ORM-Deploying-a-Blog/">this latest article</a>. It introduces the idea of dependency injection into the mix, showing how it can be used in the relationships between entities.
</p>
<blockquote>
if you've already read the two installments that precede this one, it's probable that you're familiar with the inner workings of this sample ORM. In those chapters I implemented the ORM's data access and mapping layers, along with a simple domain model. To be frank, the development of this last tier is entirely optional; however, it's useful for demonstrating the ORM's actual functionality in the deployment of a blog program, which naturally will handle some "typical" domain objects, namely blog entries, comments and authors.
</blockquote>
<p>
They share the code for creating proxy objects and, using a "poor man's dependency injection container" made from a factory method, interfaces and service classes to handle the results.
</p>]]></description>
      <pubDate>Fri, 09 Dec 2011 11:13:18 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Building an ORM in PHP: Domain Modeling]]></title>
      <guid>http://www.phpdeveloper.org/news/17159</guid>
      <link>http://www.phpdeveloper.org/news/17159</link>
      <description><![CDATA[<p>
Continuing on from the <a href="http://phpdeveloper.org/news/17146">first part</a> of their series, DevShed has posted part two of their "Building an ORM in PHP" series. This latest tutorial <a href="http://www.devshed.com/c/a/MySQL/Building-an-ORM-in-PHP-Domain-Modeling/">focuses on domain modeling</a> (and collection handling).
</p>
<blockquote>
In that first part, I implemented the ORM's data access and mapping layers. And as you'll surely recall, the entire implementation process was pretty straightforward and easy to follow. Of course, in its current state the ORM is still far from a fully-functional structure. We need to add some additional components to it, such as a domain model and the classes responsible for handling collections of entities (remember that the ORM relies heavily on the data mapper pattern to do its business properly).
</blockquote>
<p>
He stays with his "simple blog" example and shows domain models (based on an abstract entity) for Entries, Comments and Authors. His containers extend the Countable, IteratorAggregate and ArrayAccess interfaces to give them some extra abilities.
</p>]]></description>
      <pubDate>Tue, 22 Nov 2011 16:46:10 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DevShed: Building an ORM in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17146</guid>
      <link>http://www.phpdeveloper.org/news/17146</link>
      <description><![CDATA[<p>
On DevShed today there's a new tutorial showing you how to <a href="http://www.devshed.com/c/a/MySQL/Building-an-ORM-in-PHP/">build a basic ORM layer</a> on top of a MySQL database. It includes all the code you'll need (cut&paste-able, not as a download).
</p>
<blockquote>
Obviously, with so many ORMs at one's disposal for free, it seems pretty pointless to develop a custom one; are we trying to reinvent the wheel? No, of course not. But if you need to create a simple application that performs a few CRUD operations on some related domain objects and don't want to climb the learning curve of a third-party library, then implementing a custom ORM might make sense. There's alos the educational aspect of the process (yes, learning one or two things never hurts).
</blockquote>
<p>
They start you off with the creation of the "data persistence layer" (an interface first) to connect to the database, building a MySQL-specific one on top of it. Next up is the data mapper layer making things like "fetch by ID" and the insert/update/delete possible. Their simple example doesn't include anything about ORM relationships, though - just fetching simple rows.
</p>]]></description>
      <pubDate>Fri, 18 Nov 2011 09:45:15 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Jigal Sanders' Blog: A first look at Doctrine 2.1]]></title>
      <guid>http://www.phpdeveloper.org/news/16622</guid>
      <link>http://www.phpdeveloper.org/news/16622</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Jigal Sanders</i> shares some of his experience in <a href="http://blog.sanders-albek.nl/2011/07/21/a-first-look-at-doctrine-2-1/">working with Doctrine 2.1</a> in a Zend Framework-based (1.11.9) application for his database interface needs.
</p>
<blockquote>
I hadn't been using Doctrine for a while and decided to pick it up two weeks ago, as we wanted to see if we can implement it for our CMS at our office. So I setup a clean installation of the zend framework (1.11.9) and tried tried to implement Doctrine. The main goal was to see if we can reverse engineer existing databases and then start doing some queries.
</blockquote>
<p>
There were three things he found in the process that caused a few issues:
</p>
<ul>
<li>A confusing set of terms and features that weren't explained well enough to know their use
<li>Getting things like autoloaders working with the Zend Framework to make things work well together
<li>A potential bug with the "name" property on an object and some automatic namespacing Doctrine tries to do
</ul>
<blockquote>
There are already a lot of resources available on the Internet. I have looked at various configurations, like for example the '<a href="https://github.com/guilhermeblanco/ZendFramework1-Doctrine2/tree/master/library/Bisna">bisna</a>' project from Guilhere Blanco.  But I keep saying that it's really difficult and has a steep learning curve. Doctrine 1.2 was really simple. Doctrine 2.x is a lot more difficult to get into.
</blockquote>]]></description>
      <pubDate>Fri, 22 Jul 2011 10:33:08 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: From Doctrine 1 to Doctrine 2]]></title>
      <guid>http://www.phpdeveloper.org/news/15385</guid>
      <link>http://www.phpdeveloper.org/news/15385</link>
      <description><![CDATA[<p>
On DZone.com today there's a new article from <i>Giorgio Sironi</i> about <a href="http://css.dzone.com/articles/doctrine-1-doctrine-2">making the switch</a> from <a href="http://www.doctrine-project.org">Doctrine</a> 1 to Doctrine 2 and some of what might be involved.
</p>
<blockquote>
Doctrine 2 is an implementation of the Data Mapper pattern, and does not force your model classes to extend an Active Record, nor to contain details about the relational model like foreign keys. [...] Note that you will have to run your application of PHP 5.3 for Doctrine 2 to work, mainly because of the use of namespaces in it.
</blockquote>
<p>
He talks about some of the other differences including maintaining PHP classes and the metadata in them rather than just a YAML schema to map to your database. There's also a difference in how to interact directly with the Doctrine engine. Direct access has been replaced with a dependency injection approach.
</p>]]></description>
      <pubDate>Thu, 04 Nov 2010 12:48:21 -0500</pubDate>
    </item>
  </channel>
</rss>

