v

PHP ANOTATION , Reflection

· 2011-12-02 (금) 09:49:54 · 2939
PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
잘만 활용 하면, 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,187건
+
제목 글쓴이 날짜 조회
11-10-18 조회 2,649
11-10-18 조회 2,570
11-10-18 조회 2,486
11-10-17 조회 3,857
11-10-17 조회 5,134
11-10-17 조회 2,484
11-10-17 조회 2,752
11-10-17 조회 3,847
11-10-16 조회 2,521
11-10-16 조회 3,165
11-10-16 조회 3,609
11-10-15 조회 1.2만
11-10-15 조회 3,286
11-10-15 조회 3,025
11-10-15 조회 3,705
11-10-15 조회 3,688
11-10-15 조회 2,936
11-10-14 조회 2,959
11-10-13 조회 2,720
11-10-13 조회 4,502
11-10-12 조회 2,525
11-10-12 조회 2,689
11-10-12 조회 3,799
11-10-12 조회 4,095
11-10-12 조회 2,438
11-10-11 조회 2,959
11-10-11 조회 2,606
11-10-11 조회 2,785
11-10-11 조회 3,095
11-10-10 조회 2,758
11-10-10 조회 2,737
11-10-10 조회 2,445
11-10-10 조회 2,436
11-10-10 조회 2,714
11-10-10 조회 2,833
11-10-09 조회 2,641
11-10-08 조회 2,634
11-10-08 조회 4,567
11-10-08 조회 2,918
11-10-07 조회 3,133
11-10-07 조회 2,969
11-10-07 조회 3,464
11-10-06 조회 4,054
11-10-06 조회 2,616
11-10-06 조회 2,708
11-10-06 조회 3,917
11-10-06 조회 2,762
11-10-06 조회 4,302
11-10-06 조회 2,529
11-10-05 조회 2,812
11-10-05 조회 2,951
11-10-05 조회 4,045
11-10-04 조회 2,931
11-10-04 조회 5,376
11-10-04 조회 2,837
11-10-04 조회 2,386
11-10-03 조회 2,768
11-10-02 조회 2,653
11-10-02 조회 3,378
11-10-01 조회 2,409
11-10-01 조회 2,724
11-09-30 조회 2,611
11-09-30 조회 2,711
11-09-30 조회 2,894
11-09-30 조회 2,898
11-09-30 조회 3,667
11-09-30 조회 2,672
11-09-30 조회 3,101
11-09-29 조회 4,926
11-09-29 조회 2,754
11-09-29 조회 2,653
11-09-29 조회 3,061
11-09-28 조회 3,163
11-09-28 조회 3,936
11-09-28 조회 3,139
11-09-28 조회 2,515
11-09-28 조회 2,458
11-09-28 조회 2,329
11-09-28 조회 2,623
11-09-28 조회 4,128
11-09-26 조회 2,543
11-09-26 조회 2,608
11-09-26 조회 2,732
11-09-25 조회 3,072
11-09-24 조회 2,550
11-09-23 조회 2,831
11-09-23 조회 3,421
11-09-23 조회 2,550
11-09-23 조회 2,951
11-09-23 조회 2,294
11-09-22 조회 2,467
11-09-22 조회 2,876
11-09-21 조회 3,246
11-09-21 조회 3,274
11-09-20 조회 2,837
11-09-20 조회 2,667
11-09-20 조회 3,187
11-09-19 조회 2,708
11-09-19 조회 6,003
11-09-19 조회 3,801