v

PHP ANOTATION , Reflection

· 14년 전 · 1642
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,389
14년 전 조회 2,618
14년 전 조회 2,165
14년 전 조회 3,174
14년 전 조회 1,840
14년 전 조회 1,859
14년 전 조회 1,677
14년 전 조회 2,470
14년 전 조회 2,106
14년 전 조회 1,796
14년 전 조회 6,340
14년 전 조회 2,952
14년 전 조회 2,208
14년 전 조회 1,705
14년 전 조회 1만
14년 전 조회 2,618
14년 전 조회 1,632
14년 전 조회 1,662
14년 전 조회 2,505
14년 전 조회 3,050
14년 전 조회 2,576
14년 전 조회 1,810
14년 전 조회 3,099
14년 전 조회 3,046
14년 전 조회 4,067
14년 전 조회 2,162
14년 전 조회 2,322
14년 전 조회 1,859
14년 전 조회 1,914
14년 전 조회 3,158
14년 전 조회 1,943
14년 전 조회 3,441
14년 전 조회 1,668
14년 전 조회 4,542
14년 전 조회 1,718
14년 전 조회 3,132
14년 전 조회 4,505
14년 전 조회 1,768
14년 전 조회 1,958
14년 전 조회 2,314
14년 전 조회 1,856
14년 전 조회 2,399
14년 전 조회 2,267
14년 전 조회 2,410
14년 전 조회 2,145
14년 전 조회 1,752
14년 전 조회 2,202
14년 전 조회 2,208
14년 전 조회 2,088
14년 전 조회 1,643
14년 전 조회 1,595
14년 전 조회 2,012
14년 전 조회 1,523
14년 전 조회 4,099
14년 전 조회 1,546
14년 전 조회 1,931
14년 전 조회 1,584
14년 전 조회 1,606
14년 전 조회 2,860
14년 전 조회 1,914
14년 전 조회 2,356
14년 전 조회 1,639
14년 전 조회 2,213
14년 전 조회 2,724
14년 전 조회 1,790
14년 전 조회 2,262
14년 전 조회 1,782
14년 전 조회 2,144
14년 전 조회 3,604
14년 전 조회 1,640
14년 전 조회 5,784
14년 전 조회 1,649
14년 전 조회 1,818
14년 전 조회 1,669
14년 전 조회 4,382
14년 전 조회 1,466
14년 전 조회 1,792
14년 전 조회 2,108
14년 전 조회 2,124
14년 전 조회 1,585
14년 전 조회 2,218
14년 전 조회 1,672
14년 전 조회 1,564
14년 전 조회 3,228
14년 전 조회 1,950
14년 전 조회 1,538
14년 전 조회 1,523
14년 전 조회 2,566
14년 전 조회 1,720
14년 전 조회 2,136
14년 전 조회 2,115
14년 전 조회 2,721
14년 전 조회 2,801
14년 전 조회 2,071
14년 전 조회 1,708
14년 전 조회 1,631
14년 전 조회 1,858
14년 전 조회 2,042
14년 전 조회 3,501
14년 전 조회 1,527