v

PHP ANOTATION , Reflection

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'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,492
14년 전 조회 1,748
14년 전 조회 1,289
14년 전 조회 2,332
14년 전 조회 974
14년 전 조회 966
14년 전 조회 817
14년 전 조회 1,617
14년 전 조회 1,231
14년 전 조회 965
14년 전 조회 5,510
14년 전 조회 2,108
14년 전 조회 1,355
14년 전 조회 817
14년 전 조회 9,616
14년 전 조회 1,733
14년 전 조회 756
14년 전 조회 743
14년 전 조회 1,658
14년 전 조회 2,177
14년 전 조회 1,708
14년 전 조회 982
14년 전 조회 2,257
14년 전 조회 2,266
14년 전 조회 3,215
14년 전 조회 1,301
14년 전 조회 1,457
14년 전 조회 993
14년 전 조회 1,085
14년 전 조회 2,330
14년 전 조회 1,101
14년 전 조회 2,580
14년 전 조회 802
14년 전 조회 3,681
14년 전 조회 901
14년 전 조회 2,253
14년 전 조회 3,648
14년 전 조회 936
14년 전 조회 1,129
14년 전 조회 1,501
14년 전 조회 988
14년 전 조회 1,524
14년 전 조회 1,420
14년 전 조회 1,522
14년 전 조회 1,295
14년 전 조회 904
14년 전 조회 1,372
14년 전 조회 1,372
14년 전 조회 1,232
14년 전 조회 809
14년 전 조회 757
14년 전 조회 1,144
14년 전 조회 690
14년 전 조회 3,254
14년 전 조회 771
14년 전 조회 1,131
14년 전 조회 777
14년 전 조회 832
14년 전 조회 2,063
14년 전 조회 1,086
14년 전 조회 1,604
14년 전 조회 841
14년 전 조회 1,439
14년 전 조회 1,930
14년 전 조회 990
14년 전 조회 1,492
14년 전 조회 998
14년 전 조회 1,379
14년 전 조회 2,795
14년 전 조회 860
14년 전 조회 5,016
14년 전 조회 852
14년 전 조회 1,038
14년 전 조회 872
14년 전 조회 3,608
14년 전 조회 673
14년 전 조회 1,035
14년 전 조회 1,319
14년 전 조회 1,319
14년 전 조회 795
14년 전 조회 1,424
14년 전 조회 895
14년 전 조회 770
14년 전 조회 2,438
14년 전 조회 1,148
14년 전 조회 765
14년 전 조회 741
14년 전 조회 1,782
14년 전 조회 957
14년 전 조회 1,343
14년 전 조회 1,325
14년 전 조회 1,975
14년 전 조회 2,015
14년 전 조회 1,296
14년 전 조회 935
14년 전 조회 868
14년 전 조회 1,102
14년 전 조회 1,295
14년 전 조회 2,752
14년 전 조회 752