v

PHP ANOTATION , Reflection

· 14년 전 · 1677
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년 전 조회 2,432
14년 전 조회 2,656
14년 전 조회 2,191
14년 전 조회 3,203
14년 전 조회 1,871
14년 전 조회 1,906
14년 전 조회 1,710
14년 전 조회 2,493
14년 전 조회 2,135
14년 전 조회 1,839
14년 전 조회 6,378
14년 전 조회 2,987
14년 전 조회 2,242
14년 전 조회 1,735
14년 전 조회 1.1만
14년 전 조회 2,643
14년 전 조회 1,662
14년 전 조회 1,697
14년 전 조회 2,532
14년 전 조회 3,085
14년 전 조회 2,618
14년 전 조회 1,838
14년 전 조회 3,139
14년 전 조회 3,089
14년 전 조회 4,098
14년 전 조회 2,197
14년 전 조회 2,349
14년 전 조회 1,891
14년 전 조회 1,945
14년 전 조회 3,196
14년 전 조회 1,973
14년 전 조회 3,489
14년 전 조회 1,700
14년 전 조회 4,582
14년 전 조회 1,748
14년 전 조회 3,164
14년 전 조회 4,541
14년 전 조회 1,796
14년 전 조회 1,994
14년 전 조회 2,347
14년 전 조회 1,886
14년 전 조회 2,434
14년 전 조회 2,298
14년 전 조회 2,448
14년 전 조회 2,172
14년 전 조회 1,778
14년 전 조회 2,227
14년 전 조회 2,232
14년 전 조회 2,120
14년 전 조회 1,678
14년 전 조회 1,622
14년 전 조회 2,032
14년 전 조회 1,563
14년 전 조회 4,121
14년 전 조회 1,579
14년 전 조회 1,950
14년 전 조회 1,615
14년 전 조회 1,632
14년 전 조회 2,879
14년 전 조회 1,947
14년 전 조회 2,388
14년 전 조회 1,663
14년 전 조회 2,234
14년 전 조회 2,749
14년 전 조회 1,812
14년 전 조회 2,284
14년 전 조회 1,807
14년 전 조회 2,167
14년 전 조회 3,634
14년 전 조회 1,660
14년 전 조회 5,812
14년 전 조회 1,675
14년 전 조회 1,838
14년 전 조회 1,694
14년 전 조회 4,399
14년 전 조회 1,488
14년 전 조회 1,817
14년 전 조회 2,134
14년 전 조회 2,147
14년 전 조회 1,611
14년 전 조회 2,248
14년 전 조회 1,695
14년 전 조회 1,574
14년 전 조회 3,254
14년 전 조회 1,976
14년 전 조회 1,559
14년 전 조회 1,547
14년 전 조회 2,591
14년 전 조회 1,757
14년 전 조회 2,155
14년 전 조회 2,149
14년 전 조회 2,749
14년 전 조회 2,823
14년 전 조회 2,096
14년 전 조회 1,724
14년 전 조회 1,655
14년 전 조회 1,880
14년 전 조회 2,062
14년 전 조회 3,546
14년 전 조회 1,558