v

PHP ANOTATION , Reflection

· 14년 전 · 1699
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,447
14년 전 조회 2,675
14년 전 조회 2,211
14년 전 조회 3,220
14년 전 조회 1,888
14년 전 조회 1,924
14년 전 조회 1,726
14년 전 조회 2,510
14년 전 조회 2,152
14년 전 조회 1,857
14년 전 조회 6,397
14년 전 조회 3,004
14년 전 조회 2,263
14년 전 조회 1,755
14년 전 조회 1.1만
14년 전 조회 2,662
14년 전 조회 1,683
14년 전 조회 1,718
14년 전 조회 2,548
14년 전 조회 3,104
14년 전 조회 2,634
14년 전 조회 1,860
14년 전 조회 3,157
14년 전 조회 3,111
14년 전 조회 4,117
14년 전 조회 2,211
14년 전 조회 2,372
14년 전 조회 1,912
14년 전 조회 1,961
14년 전 조회 3,210
14년 전 조회 1,993
14년 전 조회 3,512
14년 전 조회 1,712
14년 전 조회 4,599
14년 전 조회 1,771
14년 전 조회 3,182
14년 전 조회 4,555
14년 전 조회 1,815
14년 전 조회 2,010
14년 전 조회 2,366
14년 전 조회 1,901
14년 전 조회 2,452
14년 전 조회 2,313
14년 전 조회 2,460
14년 전 조회 2,189
14년 전 조회 1,789
14년 전 조회 2,237
14년 전 조회 2,250
14년 전 조회 2,131
14년 전 조회 1,700
14년 전 조회 1,637
14년 전 조회 2,047
14년 전 조회 1,578
14년 전 조회 4,132
14년 전 조회 1,598
14년 전 조회 1,966
14년 전 조회 1,634
14년 전 조회 1,647
14년 전 조회 2,893
14년 전 조회 1,957
14년 전 조회 2,400
14년 전 조회 1,673
14년 전 조회 2,247
14년 전 조회 2,760
14년 전 조회 1,825
14년 전 조회 2,297
14년 전 조회 1,823
14년 전 조회 2,184
14년 전 조회 3,648
14년 전 조회 1,673
14년 전 조회 5,822
14년 전 조회 1,685
14년 전 조회 1,853
14년 전 조회 1,705
14년 전 조회 4,414
14년 전 조회 1,497
14년 전 조회 1,828
14년 전 조회 2,145
14년 전 조회 2,155
14년 전 조회 1,621
14년 전 조회 2,259
14년 전 조회 1,709
14년 전 조회 1,588
14년 전 조회 3,268
14년 전 조회 1,986
14년 전 조회 1,575
14년 전 조회 1,556
14년 전 조회 2,607
14년 전 조회 1,766
14년 전 조회 2,171
14년 전 조회 2,166
14년 전 조회 2,760
14년 전 조회 2,839
14년 전 조회 2,112
14년 전 조회 1,738
14년 전 조회 1,661
14년 전 조회 1,888
14년 전 조회 2,077
14년 전 조회 3,553
14년 전 조회 1,573