v

PHP ANOTATION , Reflection

· 14년 전 · 1671
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,424
14년 전 조회 2,653
14년 전 조회 2,186
14년 전 조회 3,200
14년 전 조회 1,865
14년 전 조회 1,896
14년 전 조회 1,705
14년 전 조회 2,490
14년 전 조회 2,130
14년 전 조회 1,824
14년 전 조회 6,372
14년 전 조회 2,982
14년 전 조회 2,237
14년 전 조회 1,730
14년 전 조회 1.1만
14년 전 조회 2,638
14년 전 조회 1,657
14년 전 조회 1,691
14년 전 조회 2,528
14년 전 조회 3,077
14년 전 조회 2,606
14년 전 조회 1,836
14년 전 조회 3,130
14년 전 조회 3,081
14년 전 조회 4,091
14년 전 조회 2,194
14년 전 조회 2,346
14년 전 조회 1,884
14년 전 조회 1,941
14년 전 조회 3,188
14년 전 조회 1,970
14년 전 조회 3,482
14년 전 조회 1,692
14년 전 조회 4,576
14년 전 조회 1,745
14년 전 조회 3,161
14년 전 조회 4,535
14년 전 조회 1,791
14년 전 조회 1,988
14년 전 조회 2,341
14년 전 조회 1,883
14년 전 조회 2,428
14년 전 조회 2,291
14년 전 조회 2,442
14년 전 조회 2,168
14년 전 조회 1,773
14년 전 조회 2,222
14년 전 조회 2,226
14년 전 조회 2,113
14년 전 조회 1,672
14년 전 조회 1,616
14년 전 조회 2,030
14년 전 조회 1,555
14년 전 조회 4,120
14년 전 조회 1,570
14년 전 조회 1,950
14년 전 조회 1,611
14년 전 조회 1,631
14년 전 조회 2,876
14년 전 조회 1,944
14년 전 조회 2,383
14년 전 조회 1,658
14년 전 조회 2,233
14년 전 조회 2,747
14년 전 조회 1,811
14년 전 조회 2,278
14년 전 조회 1,805
14년 전 조회 2,162
14년 전 조회 3,623
14년 전 조회 1,658
14년 전 조회 5,806
14년 전 조회 1,671
14년 전 조회 1,836
14년 전 조회 1,688
14년 전 조회 4,397
14년 전 조회 1,483
14년 전 조회 1,811
14년 전 조회 2,130
14년 전 조회 2,145
14년 전 조회 1,604
14년 전 조회 2,238
14년 전 조회 1,690
14년 전 조회 1,572
14년 전 조회 3,251
14년 전 조회 1,973
14년 전 조회 1,558
14년 전 조회 1,546
14년 전 조회 2,586
14년 전 조회 1,751
14년 전 조회 2,152
14년 전 조회 2,145
14년 전 조회 2,744
14년 전 조회 2,821
14년 전 조회 2,094
14년 전 조회 1,721
14년 전 조회 1,652
14년 전 조회 1,879
14년 전 조회 2,059
14년 전 조회 3,539
14년 전 조회 1,554