Login   Register  
PHP Classes
elePHPant
Icontem

File: README

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Evaldo Barbosa  >  Arroba  >  README  >  Download  
File: README
Role: Documentation
Content type: text/plain
Description: README
Class: Arroba
Extract annotation property values from classes
Author: By
Last change:
Date: 2011-12-20 04:53
Size: 1,390 bytes
 

Contents

Class file image Download
Arroba : A simple and fast way to use annotations in php.

The need is the mother of invention, everybody knows this.
I needed to use annotations in php and a library that I found did not attend me in one aspect: I would have to extend that class
and thar would be very bad to me because it would extend my classes from my other classes (ORM, plugins...).
Arroba's syntax is simple to use because programming should be so. Creating or personalizing tags to use in your projects 
is now an easier job.
See above:

/**
 * Person
 * @author Evaldo Barbosa
 * @Table(table=tb_pessoa,pkey = id)
 */
class Person {
	/**
	 * Primary Key
	 * @type= integer
	 * @notnull = true
	 * @size=255
	 * @meta (conf1=mycond, conf2=your_c)
	 * @meta1 (attribute1=value_meta1)
	 */
	private $id;
	private $nome;
	protected $hash;
}

Class Person has annotations and one of its attributes has annotations too. 
You see two distinct types of annotations and A treats both.
See how to implement it with Arroba:

//To instantiate Arroba
$ref = new \Arroba\Arroba("Person");

//Getting a specific value of key of class annotation
	echo $ref->getClassAnnotation('@Model')->table;

//Getting a specific value of key of attribute annotation
	echo $ref->getPropertyAnnotation("id", "@meta1")->attribute1;
		
Why to get one annotation at a time?
Because you should know each annotation to treat each one individually.