News Feed
Sections




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

NetTuts.com:
The Repository Design Pattern
November 26, 2013 @ 11:53:16

While design patterns are a wider topic than just PHP, the NetTuts.com site has posted a new tutorial looking at the Repository Pattern and uses PHP and PHPUnit to illustrate how the pattern works. They looks at the structure of the pattern at a high level and provide a more "real world" example too.

The Repository Design Pattern, defined by Eric Evens in his Domain Driven Design book, is one of the most useful and most widely applicable design patterns ever invented. Any application has to work with persistence and with some kind of list of items. These can be users, products, networks, disks, or whatever your application is about. If you have a blog for example, you have to deal with lists of blog posts and lists of comments. The problem that all of these list management logics have in common is how to connect business logic, factories and persistence.

They start with an overview of the pattern and some of the problems that it can help to solve. They also briefly mention the Gateway pattern that will be used in the examples to pull information into the Repository. After covering some of the basic concepts, they get into the code (going the TDD route) showing how to manage comments, like from a blog, inside a repository. It implements a "Comment" class, a persistence mechanism (the Gateway) and a Factory class that takes in the comment data and returns a correctly formatted object. Finally, they make the repository class and show how to add and retrieve comments from its internal data set.

0 comments voice your opinion now!
designpattern repository gateway factory persistence tutorial

Link: http://net.tutsplus.com/tutorials/php/the-repository-design-pattern/

blog comments powered by Disqus

Similar Posts

Michelangelo van Dam: Running Apigility on Azure

CodeGeekz: Cropping Images in PHP Based on their Entropy

Andrew Johnstone's Blog: Emailing Attachments: Exim Filters and PHP streams

ThinkPHP Blog: Accessing NTLM secured resources with PHP

Arvind Bhardwaj's Blog: How to Test PHP Emails on Localhost


Community Events

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


language podcast api community laravel conference performance introduction opinion example framework interview symfony2 application php7 release series configure part2 voicesoftheelephpant

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