천

PHP ANOTATION , Reflection 입니다.

· 2015-12-05 (토) 20:43:57 · 2752

PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
http://code.google.com/p/addendum/
 
 
 
잘만 활용 하면, spring framework 장점만 경량화 하여
 
 php 진영에서도 ... framework 도 나오지 않을가 하는

생각을 문득 해봤습니다.

 
 
------------------------------------------------------------------
 
 
 
 
 
/** @Table("people") */
class Person {
   // some code
}
 
 
 
$reflection = new ReflectionAnnotatedClass('Person'); // by class name
$reflection->getAnnotation('Table')->value; // contains string "people"
 
 
 
----------------------------------------------------------------------
 
 
 
class RolesAllowed extends Annotation {}
 
/** @RolesAllowed({'admin', 'web-editor'}) */
class CMS {
 // some code
}
 
$reflection = new ReflectionAnnotatedClass('CMS');
$annotation = $reflection->getAnnotation('RolesAllowed');
$annotation->value; // contains array('admin', 'web-editor'
 
 
 
 
 
-------------------------------------------------------------
 
 
 
/** @Mapping(inheritance = @SingleTableInheritance, columns = {@ColumnMapping('id'), @ColumnMapping('name')}) */
class Person {}
 
$reflection = new ReflectionAnnotatedClass('Person');
$annotation = $reflection->getAnnotation('Mapping');
$annotation->inheritance; // SingleTableInheritance annotation
$annotation->columns; // array of ColumnMapping annotations
$annotation->columns[0]->value; // 'id'

|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
16-03-02 조회 3,215
16-01-19 조회 2,497
15-12-23 조회 2,807
15-12-08 조회 3,614
14-10-30 조회 5,660
14-06-06 조회 5,495
12-08-30 조회 3,852
12-08-20 조회 3,777
12-07-15 조회 5,105
12-07-13 조회 3,583
12-07-06 조회 3,786
12-06-27 조회 3,322
12-06-23 조회 3,519
12-05-03 조회 5,140
12-04-20 조회 4,089
12-03-29 조회 4,580
12-03-22 조회 4,662
12-03-22 조회 3,465
12-03-21 조회 3,242
12-03-11 조회 3,679
12-03-06 조회 4,218
12-02-22 조회 4,493
12-02-17 조회 3,292
12-02-17 조회 6,138
12-02-14 조회 6,065
12-02-06 조회 4,217
12-01-18 조회 3,181
12-01-06 조회 3,401
11-12-30 조회 3,871
11-12-30 조회 7,017
11-12-21 조회 3,194
11-12-21 조회 4,202
11-12-16 조회 3,236
11-12-15 조회 3,281
11-12-15 조회 3,384
11-12-15 조회 4,176
11-12-09 조회 3,198
11-12-09 조회 3,272
11-12-07 조회 2,840
11-12-07 조회 3,926
11-12-05 조회 4,378
11-12-02 조회 3,818
11-12-01 조회 2,680
11-12-01 조회 2,731
11-12-01 조회 2,716