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,475
14년 전 조회 1,730
14년 전 조회 1,280
14년 전 조회 2,307
14년 전 조회 959
14년 전 조회 959
14년 전 조회 802
14년 전 조회 1,607
14년 전 조회 1,223
14년 전 조회 940
14년 전 조회 5,480
14년 전 조회 2,083
14년 전 조회 1,327
14년 전 조회 805
14년 전 조회 9,600
14년 전 조회 1,712
14년 전 조회 748
14년 전 조회 723
14년 전 조회 1,616
14년 전 조회 2,161
14년 전 조회 1,698
14년 전 조회 965
14년 전 조회 2,235
14년 전 조회 2,238
14년 전 조회 3,177
14년 전 조회 1,277
14년 전 조회 1,443
14년 전 조회 979
14년 전 조회 1,063
14년 전 조회 2,307
14년 전 조회 1,088
14년 전 조회 2,558
14년 전 조회 786
14년 전 조회 3,667
14년 전 조회 885
14년 전 조회 2,243
14년 전 조회 3,634
14년 전 조회 929
14년 전 조회 1,110
14년 전 조회 1,479
14년 전 조회 976
14년 전 조회 1,510
14년 전 조회 1,400
14년 전 조회 1,519
14년 전 조회 1,263
14년 전 조회 892
14년 전 조회 1,358
14년 전 조회 1,356
14년 전 조회 1,222
14년 전 조회 788
14년 전 조회 749
14년 전 조회 1,116
14년 전 조회 679
14년 전 조회 3,242
14년 전 조회 760
14년 전 조회 1,119
14년 전 조회 763
14년 전 조회 805
14년 전 조회 2,041
14년 전 조회 1,069
14년 전 조회 1,582
14년 전 조회 820
14년 전 조회 1,434
14년 전 조회 1,924
14년 전 조회 976
14년 전 조회 1,476
14년 전 조회 987
14년 전 조회 1,360
14년 전 조회 2,775
14년 전 조회 849
14년 전 조회 4,986
14년 전 조회 842
14년 전 조회 1,023
14년 전 조회 860
14년 전 조회 3,583
14년 전 조회 658
14년 전 조회 1,012
14년 전 조회 1,299
14년 전 조회 1,307
14년 전 조회 782
14년 전 조회 1,415
14년 전 조회 888
14년 전 조회 761
14년 전 조회 2,430
14년 전 조회 1,130
14년 전 조회 756
14년 전 조회 731
14년 전 조회 1,772
14년 전 조회 929
14년 전 조회 1,331
14년 전 조회 1,312
14년 전 조회 1,945
14년 전 조회 2,008
14년 전 조회 1,289
14년 전 조회 921
14년 전 조회 854
14년 전 조회 1,092
14년 전 조회 1,286
14년 전 조회 2,723
14년 전 조회 742