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,302
14년 전 조회 1,565
14년 전 조회 1,123
14년 전 조회 2,120
14년 전 조회 795
14년 전 조회 803
14년 전 조회 633
14년 전 조회 1,438
14년 전 조회 1,052
14년 전 조회 770
14년 전 조회 5,297
14년 전 조회 1,915
14년 전 조회 1,147
14년 전 조회 649
14년 전 조회 9,444
14년 전 조회 1,560
14년 전 조회 579
14년 전 조회 562
14년 전 조회 1,429
14년 전 조회 2,007
14년 전 조회 1,555
14년 전 조회 809
14년 전 조회 2,053
14년 전 조회 2,063
14년 전 조회 3,005
14년 전 조회 1,110
14년 전 조회 1,300
14년 전 조회 820
14년 전 조회 906
14년 전 조회 2,128
14년 전 조회 922
14년 전 조회 2,387
14년 전 조회 632
14년 전 조회 3,502
14년 전 조회 724
14년 전 조회 2,080
14년 전 조회 3,465
14년 전 조회 775
14년 전 조회 948
14년 전 조회 1,311
14년 전 조회 809
14년 전 조회 1,321
14년 전 조회 1,243
14년 전 조회 1,356
14년 전 조회 1,100
14년 전 조회 736
14년 전 조회 1,204
14년 전 조회 1,185
14년 전 조회 1,062
14년 전 조회 616
14년 전 조회 597
14년 전 조회 944
14년 전 조회 510
14년 전 조회 3,076
14년 전 조회 589
14년 전 조회 953
14년 전 조회 605
14년 전 조회 630
14년 전 조회 1,864
14년 전 조회 920
14년 전 조회 1,400
14년 전 조회 662
14년 전 조회 1,291
14년 전 조회 1,772
14년 전 조회 816
14년 전 조회 1,329
14년 전 조회 825
14년 전 조회 1,189
14년 전 조회 2,617
14년 전 조회 675
14년 전 조회 4,799
14년 전 조회 687
14년 전 조회 875
14년 전 조회 719
14년 전 조회 3,411
14년 전 조회 520
14년 전 조회 855
14년 전 조회 1,150
14년 전 조회 1,149
14년 전 조회 641
14년 전 조회 1,245
14년 전 조회 724
14년 전 조회 615
14년 전 조회 2,269
14년 전 조회 962
14년 전 조회 593
14년 전 조회 593
14년 전 조회 1,619
14년 전 조회 769
14년 전 조회 1,175
14년 전 조회 1,162
14년 전 조회 1,771
14년 전 조회 1,846
14년 전 조회 1,124
14년 전 조회 784
14년 전 조회 714
14년 전 조회 963
14년 전 조회 1,119
14년 전 조회 2,530
14년 전 조회 589
🐛 버그신고