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,309
14년 전 조회 1,567
14년 전 조회 1,125
14년 전 조회 2,123
14년 전 조회 799
14년 전 조회 805
14년 전 조회 641
14년 전 조회 1,440
14년 전 조회 1,053
14년 전 조회 776
14년 전 조회 5,299
14년 전 조회 1,923
14년 전 조회 1,153
14년 전 조회 651
14년 전 조회 9,449
14년 전 조회 1,563
14년 전 조회 584
14년 전 조회 568
14년 전 조회 1,434
14년 전 조회 2,010
14년 전 조회 1,559
14년 전 조회 812
14년 전 조회 2,058
14년 전 조회 2,064
14년 전 조회 3,007
14년 전 조회 1,112
14년 전 조회 1,304
14년 전 조회 824
14년 전 조회 910
14년 전 조회 2,135
14년 전 조회 924
14년 전 조회 2,392
14년 전 조회 638
14년 전 조회 3,505
14년 전 조회 727
14년 전 조회 2,087
14년 전 조회 3,467
14년 전 조회 780
14년 전 조회 950
14년 전 조회 1,313
14년 전 조회 812
14년 전 조회 1,326
14년 전 조회 1,245
14년 전 조회 1,361
14년 전 조회 1,102
14년 전 조회 740
14년 전 조회 1,206
14년 전 조회 1,189
14년 전 조회 1,063
14년 전 조회 621
14년 전 조회 604
14년 전 조회 947
14년 전 조회 512
14년 전 조회 3,082
14년 전 조회 592
14년 전 조회 957
14년 전 조회 608
14년 전 조회 638
14년 전 조회 1,869
14년 전 조회 922
14년 전 조회 1,402
14년 전 조회 666
14년 전 조회 1,296
14년 전 조회 1,775
14년 전 조회 822
14년 전 조회 1,331
14년 전 조회 828
14년 전 조회 1,192
14년 전 조회 2,620
14년 전 조회 683
14년 전 조회 4,802
14년 전 조회 692
14년 전 조회 880
14년 전 조회 724
14년 전 조회 3,415
14년 전 조회 524
14년 전 조회 859
14년 전 조회 1,152
14년 전 조회 1,154
14년 전 조회 644
14년 전 조회 1,249
14년 전 조회 726
14년 전 조회 618
14년 전 조회 2,272
14년 전 조회 966
14년 전 조회 596
14년 전 조회 595
14년 전 조회 1,621
14년 전 조회 771
14년 전 조회 1,179
14년 전 조회 1,164
14년 전 조회 1,772
14년 전 조회 1,849
14년 전 조회 1,125
14년 전 조회 790
14년 전 조회 717
14년 전 조회 966
14년 전 조회 1,119
14년 전 조회 2,533
14년 전 조회 594
🐛 버그신고