News Feed
Sections




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

PHPMaster.com:
Handling Collections of Aggregate Roots - the Repository Pattern
May 17, 2012 @ 08:44:37

On PHPMaster.com today they have a new tutorial focusing on using the Repository (a part of the domain driven design architecture) to enhance your model's current functionality.

Unlike mappers, though, which are part of the infrastructure, a repository characterizes itself as speaking the model's language, as it's intimately bound to it. And because of its implicit dependency on the mappers, it preserves the persistence ignorance as well, therefore providing a higher level of data abstraction, much closer to the domain objects.

Included in the tutorial is the full code you'll need to create a simple UserInterface class and a User model that extends it. He also makes a UserCollection class to handle working with multiple User objects and a UserMapper to handle the actual data source fetching. Finally, he implements the Repository on top of this base structure showing how it lays on top of everything via the UserMapperInterface instance. At the end some example code showing it in use is also included - making the PDO connection, creating the UserRepository and fetching by a few different data types (email, name and role).

0 comments voice your opinion now!
repository pattern domaindriven architecture tutorial mapper


blog comments powered by Disqus

Similar Posts

Abhinav Singh's Blog: MEMQ : Fast queue implementation using Memcached and PHP only

Joshua Thijssen's Blog: PHPShout : a shoutcast streamer in PHP

Padraic Brady's Blog: ZF Blog App - Part 4: Design with Blueprint CSS & Zend_Layout

Alex Bilbie's Blog: MongoDB + CodeIgniter 101 (Part 1)

AWS PHP Development: Testing Webhooks Locally for Amazon SNS


Community Events





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


language interview code list release threedevsandamaybe introduction project bugfix laravel application configure library community framework api wordpress podcast developer series

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