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,301
14년 전 조회 1,556
14년 전 조회 1,117
14년 전 조회 2,114
14년 전 조회 789
14년 전 조회 801
14년 전 조회 630
14년 전 조회 1,431
14년 전 조회 1,045
14년 전 조회 767
14년 전 조회 5,295
14년 전 조회 1,911
14년 전 조회 1,145
14년 전 조회 646
14년 전 조회 9,440
14년 전 조회 1,555
14년 전 조회 572
14년 전 조회 555
14년 전 조회 1,423
14년 전 조회 2,003
14년 전 조회 1,551
14년 전 조회 803
14년 전 조회 2,052
14년 전 조회 2,055
14년 전 조회 3,003
14년 전 조회 1,109
14년 전 조회 1,294
14년 전 조회 812
14년 전 조회 901
14년 전 조회 2,123
14년 전 조회 915
14년 전 조회 2,384
14년 전 조회 627
14년 전 조회 3,499
14년 전 조회 719
14년 전 조회 2,076
14년 전 조회 3,462
14년 전 조회 770
14년 전 조회 947
14년 전 조회 1,307
14년 전 조회 804
14년 전 조회 1,312
14년 전 조회 1,241
14년 전 조회 1,353
14년 전 조회 1,098
14년 전 조회 731
14년 전 조회 1,201
14년 전 조회 1,180
14년 전 조회 1,056
14년 전 조회 613
14년 전 조회 592
14년 전 조회 939
14년 전 조회 502
14년 전 조회 3,071
14년 전 조회 587
14년 전 조회 947
14년 전 조회 599
14년 전 조회 627
14년 전 조회 1,862
14년 전 조회 912
14년 전 조회 1,399
14년 전 조회 656
14년 전 조회 1,285
14년 전 조회 1,765
14년 전 조회 808
14년 전 조회 1,324
14년 전 조회 821
14년 전 조회 1,186
14년 전 조회 2,611
14년 전 조회 670
14년 전 조회 4,795
14년 전 조회 680
14년 전 조회 869
14년 전 조회 715
14년 전 조회 3,405
14년 전 조회 516
14년 전 조회 849
14년 전 조회 1,146
14년 전 조회 1,142
14년 전 조회 634
14년 전 조회 1,238
14년 전 조회 720
14년 전 조회 609
14년 전 조회 2,264
14년 전 조회 958
14년 전 조회 587
14년 전 조회 584
14년 전 조회 1,614
14년 전 조회 766
14년 전 조회 1,170
14년 전 조회 1,159
14년 전 조회 1,766
14년 전 조회 1,843
14년 전 조회 1,116
14년 전 조회 779
14년 전 조회 710
14년 전 조회 955
14년 전 조회 1,115
14년 전 조회 2,526
14년 전 조회 587
🐛 버그신고