v

PHP ANOTATION , Reflection

· 14년 전 · 1721
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,476
14년 전 조회 2,697
14년 전 조회 2,238
14년 전 조회 3,242
14년 전 조회 1,908
14년 전 조회 1,940
14년 전 조회 1,749
14년 전 조회 2,534
14년 전 조회 2,174
14년 전 조회 1,882
14년 전 조회 6,427
14년 전 조회 3,029
14년 전 조회 2,287
14년 전 조회 1,783
14년 전 조회 1.1만
14년 전 조회 2,686
14년 전 조회 1,699
14년 전 조회 1,741
14년 전 조회 2,573
14년 전 조회 3,131
14년 전 조회 2,657
14년 전 조회 1,881
14년 전 조회 3,192
14년 전 조회 3,132
14년 전 조회 4,131
14년 전 조회 2,239
14년 전 조회 2,396
14년 전 조회 1,936
14년 전 조회 1,986
14년 전 조회 3,233
14년 전 조회 2,019
14년 전 조회 3,533
14년 전 조회 1,746
14년 전 조회 4,623
14년 전 조회 1,789
14년 전 조회 3,198
14년 전 조회 4,587
14년 전 조회 1,834
14년 전 조회 2,031
14년 전 조회 2,386
14년 전 조회 1,914
14년 전 조회 2,472
14년 전 조회 2,331
14년 전 조회 2,478
14년 전 조회 2,210
14년 전 조회 1,801
14년 전 조회 2,265
14년 전 조회 2,265
14년 전 조회 2,149
14년 전 조회 1,722
14년 전 조회 1,661
14년 전 조회 2,074
14년 전 조회 1,599
14년 전 조회 4,149
14년 전 조회 1,618
14년 전 조회 1,989
14년 전 조회 1,656
14년 전 조회 1,678
14년 전 조회 2,907
14년 전 조회 1,976
14년 전 조회 2,420
14년 전 조회 1,693
14년 전 조회 2,264
14년 전 조회 2,782
14년 전 조회 1,845
14년 전 조회 2,319
14년 전 조회 1,841
14년 전 조회 2,205
14년 전 조회 3,672
14년 전 조회 1,687
14년 전 조회 5,838
14년 전 조회 1,703
14년 전 조회 1,871
14년 전 조회 1,721
14년 전 조회 4,436
14년 전 조회 1,521
14년 전 조회 1,844
14년 전 조회 2,167
14년 전 조회 2,171
14년 전 조회 1,642
14년 전 조회 2,274
14년 전 조회 1,727
14년 전 조회 1,612
14년 전 조회 3,290
14년 전 조회 2,009
14년 전 조회 1,598
14년 전 조회 1,579
14년 전 조회 2,627
14년 전 조회 1,788
14년 전 조회 2,188
14년 전 조회 2,187
14년 전 조회 2,780
14년 전 조회 2,866
14년 전 조회 2,128
14년 전 조회 1,759
14년 전 조회 1,687
14년 전 조회 1,912
14년 전 조회 2,099
14년 전 조회 3,573
14년 전 조회 1,586