[nycphp-talk] Metadata/Attributes in PHP
Jon Gilkison
jon.gilkison at gmail.com
Mon Jun 16 08:03:55 EDT 2008
We use it in a lot of place here at massify. For our ORM, we use it
similar to how I have it in the example in that blog post. We also
use it on our controllers to specify pre and post filters to call
before we route the incoming HTTP request.
The place we use it the most is in our Model controllers. For our
internal API's, we have a base controller class that can perform basic
CRUD and search on any given model. To enable this for a specific
model, we inherit that controller and dress it with metadata to tell
it which model to use, how to map query parameters to search
parameters, post fields to model properties, etc. We can literally
kick out an API for the model in a few minutes.
You could do this without the metadata, but it makes it easier. We've
found anyways.
Best,
Jon.
On Jun 16, 2008, at 7:31 AM, Justin Dearing wrote:
> On Mon, Jun 16, 2008 at 5:51 AM, Jon Gilkison
> <jon.gilkison at gmail.com> wrote:
>> I wrote a class that allows you to do metadata programming in PHP
>> (attributes in C#/annotations in Java). You can fetch the code and
>> the
>> post: http://interfacelab.com/metadataattributes-in-php/
>
> Interesting idea, what types of attributes do you define?
>
> I like the concept of the ObsoleteAttribute in .net and think this
> would be one area where I would use that in PHP. Since I've never
> defined a custom attribute in .NET, and only modified a custome
> attribute class once, I can live without them just fine without them
> in PHP for most purposes. If I have to inherit a class instead of
> decorating functions with attributes, to create a web service so be
> it.
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
jon gilkison
chief technology officer / massify.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20080616/cdedc097/attachment.html>
More information about the talk
mailing list