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,303
14년 전 조회 1,566
14년 전 조회 1,124
14년 전 조회 2,121
14년 전 조회 795
14년 전 조회 803
14년 전 조회 635
14년 전 조회 1,438
14년 전 조회 1,052
14년 전 조회 772
14년 전 조회 5,298
14년 전 조회 1,916
14년 전 조회 1,149
14년 전 조회 649
14년 전 조회 9,445
14년 전 조회 1,561
14년 전 조회 581
14년 전 조회 564
14년 전 조회 1,429
14년 전 조회 2,008
14년 전 조회 1,555
14년 전 조회 810
14년 전 조회 2,053
14년 전 조회 2,063
14년 전 조회 3,006
14년 전 조회 1,110
14년 전 조회 1,300
14년 전 조회 820
14년 전 조회 907
14년 전 조회 2,129
14년 전 조회 922
14년 전 조회 2,388
14년 전 조회 634
14년 전 조회 3,503
14년 전 조회 724
14년 전 조회 2,080
14년 전 조회 3,466
14년 전 조회 775
14년 전 조회 948
14년 전 조회 1,311
14년 전 조회 810
14년 전 조회 1,323
14년 전 조회 1,243
14년 전 조회 1,356
14년 전 조회 1,100
14년 전 조회 736
14년 전 조회 1,204
14년 전 조회 1,186
14년 전 조회 1,062
14년 전 조회 618
14년 전 조회 598
14년 전 조회 944
14년 전 조회 511
14년 전 조회 3,077
14년 전 조회 589
14년 전 조회 954
14년 전 조회 606
14년 전 조회 631
14년 전 조회 1,865
14년 전 조회 920
14년 전 조회 1,401
14년 전 조회 662
14년 전 조회 1,292
14년 전 조회 1,773
14년 전 조회 816
14년 전 조회 1,329
14년 전 조회 826
14년 전 조회 1,190
14년 전 조회 2,618
14년 전 조회 677
14년 전 조회 4,799
14년 전 조회 687
14년 전 조회 877
14년 전 조회 719
14년 전 조회 3,412
14년 전 조회 521
14년 전 조회 855
14년 전 조회 1,150
14년 전 조회 1,150
14년 전 조회 642
14년 전 조회 1,246
14년 전 조회 724
14년 전 조회 615
14년 전 조회 2,269
14년 전 조회 963
14년 전 조회 593
14년 전 조회 593
14년 전 조회 1,619
14년 전 조회 769
14년 전 조회 1,176
14년 전 조회 1,162
14년 전 조회 1,772
14년 전 조회 1,847
14년 전 조회 1,124
14년 전 조회 785
14년 전 조회 716
14년 전 조회 964
14년 전 조회 1,119
14년 전 조회 2,530
14년 전 조회 590
🐛 버그신고