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,348
14년 전 조회 1,599
14년 전 조회 1,160
14년 전 조회 2,164
14년 전 조회 840
14년 전 조회 845
14년 전 조회 678
14년 전 조회 1,472
14년 전 조회 1,093
14년 전 조회 815
14년 전 조회 5,338
14년 전 조회 1,967
14년 전 조회 1,191
14년 전 조회 689
14년 전 조회 9,488
14년 전 조회 1,596
14년 전 조회 628
14년 전 조회 605
14년 전 조회 1,468
14년 전 조회 2,044
14년 전 조회 1,597
14년 전 조회 847
14년 전 조회 2,101
14년 전 조회 2,103
14년 전 조회 3,040
14년 전 조회 1,152
14년 전 조회 1,337
14년 전 조회 856
14년 전 조회 947
14년 전 조회 2,167
14년 전 조회 960
14년 전 조회 2,425
14년 전 조회 670
14년 전 조회 3,536
14년 전 조회 750
14년 전 조회 2,124
14년 전 조회 3,514
14년 전 조회 817
14년 전 조회 980
14년 전 조회 1,345
14년 전 조회 848
14년 전 조회 1,367
14년 전 조회 1,277
14년 전 조회 1,390
14년 전 조회 1,134
14년 전 조회 767
14년 전 조회 1,234
14년 전 조회 1,228
14년 전 조회 1,100
14년 전 조회 661
14년 전 조회 631
14년 전 조회 988
14년 전 조회 553
14년 전 조회 3,115
14년 전 조회 627
14년 전 조회 994
14년 전 조회 631
14년 전 조회 671
14년 전 조회 1,900
14년 전 조회 948
14년 전 조회 1,438
14년 전 조회 698
14년 전 조회 1,329
14년 전 조회 1,805
14년 전 조회 849
14년 전 조회 1,364
14년 전 조회 863
14년 전 조회 1,228
14년 전 조회 2,651
14년 전 조회 724
14년 전 조회 4,833
14년 전 조회 728
14년 전 조회 911
14년 전 조회 762
14년 전 조회 3,451
14년 전 조회 556
14년 전 조회 892
14년 전 조회 1,186
14년 전 조회 1,185
14년 전 조회 682
14년 전 조회 1,285
14년 전 조회 756
14년 전 조회 652
14년 전 조회 2,297
14년 전 조회 998
14년 전 조회 630
14년 전 조회 621
14년 전 조회 1,655
14년 전 조회 800
14년 전 조회 1,211
14년 전 조회 1,190
14년 전 조회 1,802
14년 전 조회 1,880
14년 전 조회 1,153
14년 전 조회 820
14년 전 조회 749
14년 전 조회 999
14년 전 조회 1,155
14년 전 조회 2,568
14년 전 조회 622
🐛 버그신고