News Feed
Sections




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

Gonzalo Ayuso's Blog:
Function decorators in PHP with PHPDoc and Annotations
February 01, 2011 @ 13:13:04

Gonzalo Ayuso has a new post to his blog looking at some of the recent work he's done with PHPDoc and annotations to create "function decorators" in his code.

The idea is to solve the same problem I had when I wrote the previous article. I want to protect the execution of certain functions in a class to only being executed if the user is logged on. [...] The solution with interfaces is clean and simple (no extra libraries need and no reflection need too). The problem is that I can use it only for all the functions of the class.

He gives an example class with four different methods (one with annotations) and his annotation parsing class that runs the predispatch and postdispatch methods based on those annotations. He also shows another examples using an abstract class.

3 comments voice your opinion now!
annotations decorator phpdocumentor tutorial


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Working with RAR, LZF and BZ2 Compression Formats in PHP

PHP Web Services: How to configure https for Apache2.2 and consume PHP web services over https

WebReference.com: XML and PHP Simplified

YouTube.com: Installing Zend Server on Linux in 4 minutes and 37 seconds

Zend Developer Zone: AJAX Chat Tutorial Part 6 : Updating the User List


Community Events

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


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

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