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,340
14년 전 조회 1,595
14년 전 조회 1,154
14년 전 조회 2,156
14년 전 조회 831
14년 전 조회 839
14년 전 조회 671
14년 전 조회 1,467
14년 전 조회 1,088
14년 전 조회 806
14년 전 조회 5,332
14년 전 조회 1,960
14년 전 조회 1,183
14년 전 조회 682
14년 전 조회 9,481
14년 전 조회 1,593
14년 전 조회 624
14년 전 조회 597
14년 전 조회 1,461
14년 전 조회 2,040
14년 전 조회 1,587
14년 전 조회 844
14년 전 조회 2,097
14년 전 조회 2,096
14년 전 조회 3,037
14년 전 조회 1,145
14년 전 조회 1,330
14년 전 조회 849
14년 전 조회 942
14년 전 조회 2,162
14년 전 조회 957
14년 전 조회 2,418
14년 전 조회 663
14년 전 조회 3,533
14년 전 조회 744
14년 전 조회 2,119
14년 전 조회 3,507
14년 전 조회 808
14년 전 조회 974
14년 전 조회 1,340
14년 전 조회 840
14년 전 조회 1,359
14년 전 조회 1,276
14년 전 조회 1,382
14년 전 조회 1,130
14년 전 조회 761
14년 전 조회 1,232
14년 전 조회 1,218
14년 전 조회 1,096
14년 전 조회 654
14년 전 조회 628
14년 전 조회 979
14년 전 조회 543
14년 전 조회 3,108
14년 전 조회 614
14년 전 조회 982
14년 전 조회 629
14년 전 조회 664
14년 전 조회 1,893
14년 전 조회 944
14년 전 조회 1,433
14년 전 조회 692
14년 전 조회 1,323
14년 전 조회 1,801
14년 전 조회 845
14년 전 조회 1,359
14년 전 조회 858
14년 전 조회 1,223
14년 전 조회 2,646
14년 전 조회 717
14년 전 조회 4,829
14년 전 조회 719
14년 전 조회 902
14년 전 조회 756
14년 전 조회 3,439
14년 전 조회 549
14년 전 조회 881
14년 전 조회 1,182
14년 전 조회 1,180
14년 전 조회 674
14년 전 조회 1,282
14년 전 조회 748
14년 전 조회 645
14년 전 조회 2,294
14년 전 조회 992
14년 전 조회 622
14년 전 조회 618
14년 전 조회 1,649
14년 전 조회 795
14년 전 조회 1,203
14년 전 조회 1,182
14년 전 조회 1,798
14년 전 조회 1,876
14년 전 조회 1,145
14년 전 조회 813
14년 전 조회 742
14년 전 조회 991
14년 전 조회 1,147
14년 전 조회 2,557
14년 전 조회 611
🐛 버그신고