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:
An Intro to Virtual Proxies, Part 1
April 19, 2012 @ 08:52:44

On PHPMaster.com today there's a new tutorial from Alejandro Gervasio about using virtual proxies in your application - a method in development that provides a layer of abstraction on top of domain objects and makes it more efficient to work with (and lazy load) them.

Often referenced by a few other fancy names, the substitute is generically called a virtual proxy, a sort of stand-in that exploits the neatness of Polymorphism and interacts with the actual domain objects. Proxies aren't new to PHP. Doctrine and Zend Framework 2.x make use of them, although with different aims. On behalf of a didactic cause, however, it would be pretty instructive to implement some custom proxy classes and use them for lazy-loading a few basic aggregates from the database, this way illustrating how virtual proxies do their stuff under the hood.

He starts off by setting up a domain model for a "Post" and "Author" - a typical blog example.Based on the definition of these classes, he creates a mapper class to generate Author objects and an "AuthorProxy" class that uses a "loadAuthor" method to only load in the author's details when a property is requested. He gives a bit more code showing it in action and the difference between using the normal Author and AuthorProxy class.

0 comments voice your opinion now!
virtual proxy tutorial blog author post interface


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Validating PHP User Sessions

Daniel Krook's Blog: Migrating PHP applications to DB2

NETTUTS.com: Create a PHP5 Framework - Part 2

Job Posting: Active Media Architects Seeks PHP Web Application Programmer (St. Clair Shores, MI)

Stefan Mischook's Blog: Turning on display_errors in WAMP - Video Tutorial


Community Events

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


podcast laravel opinion xdebug api voicesoftheelephpant example extension release interview performance library version symfony2 framework introduction series php7 community conference

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