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,558
14년 전 조회 1,118
14년 전 조회 2,116
14년 전 조회 792
14년 전 조회 801
14년 전 조회 630
14년 전 조회 1,434
14년 전 조회 1,049
14년 전 조회 767
14년 전 조회 5,296
14년 전 조회 1,911
14년 전 조회 1,147
14년 전 조회 649
14년 전 조회 9,441
14년 전 조회 1,559
14년 전 조회 576
14년 전 조회 557
14년 전 조회 1,427
14년 전 조회 2,006
14년 전 조회 1,552
14년 전 조회 804
14년 전 조회 2,053
14년 전 조회 2,061
14년 전 조회 3,004
14년 전 조회 1,109
14년 전 조회 1,295
14년 전 조회 818
14년 전 조회 904
14년 전 조회 2,127
14년 전 조회 918
14년 전 조회 2,385
14년 전 조회 631
14년 전 조회 3,501
14년 전 조회 720
14년 전 조회 2,077
14년 전 조회 3,463
14년 전 조회 773
14년 전 조회 947
14년 전 조회 1,307
14년 전 조회 807
14년 전 조회 1,319
14년 전 조회 1,241
14년 전 조회 1,356
14년 전 조회 1,098
14년 전 조회 734
14년 전 조회 1,201
14년 전 조회 1,183
14년 전 조회 1,057
14년 전 조회 614
14년 전 조회 597
14년 전 조회 942
14년 전 조회 506
14년 전 조회 3,074
14년 전 조회 588
14년 전 조회 950
14년 전 조회 600
14년 전 조회 629
14년 전 조회 1,862
14년 전 조회 919
14년 전 조회 1,399
14년 전 조회 659
14년 전 조회 1,286
14년 전 조회 1,770
14년 전 조회 811
14년 전 조회 1,328
14년 전 조회 822
14년 전 조회 1,188
14년 전 조회 2,615
14년 전 조회 673
14년 전 조회 4,797
14년 전 조회 683
14년 전 조회 871
14년 전 조회 717
14년 전 조회 3,409
14년 전 조회 517
14년 전 조회 850
14년 전 조회 1,146
14년 전 조회 1,145
14년 전 조회 639
14년 전 조회 1,244
14년 전 조회 720
14년 전 조회 615
14년 전 조회 2,265
14년 전 조회 959
14년 전 조회 591
14년 전 조회 587
14년 전 조회 1,616
14년 전 조회 768
14년 전 조회 1,172
14년 전 조회 1,160
14년 전 조회 1,769
14년 전 조회 1,845
14년 전 조회 1,119
14년 전 조회 783
14년 전 조회 710
14년 전 조회 959
14년 전 조회 1,116
14년 전 조회 2,528
14년 전 조회 588
🐛 버그신고