v

PHP ANOTATION , Reflection

· 14년 전 · 1601
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,344
14년 전 조회 2,577
14년 전 조회 2,119
14년 전 조회 3,133
14년 전 조회 1,786
14년 전 조회 1,807
14년 전 조회 1,630
14년 전 조회 2,430
14년 전 조회 2,061
14년 전 조회 1,759
14년 전 조회 6,308
14년 전 조회 2,903
14년 전 조회 2,162
14년 전 조회 1,667
14년 전 조회 1만
14년 전 조회 2,573
14년 전 조회 1,587
14년 전 조회 1,599
14년 전 조회 2,448
14년 전 조회 3,003
14년 전 조회 2,511
14년 전 조회 1,763
14년 전 조회 3,050
14년 전 조회 3,003
14년 전 조회 4,016
14년 전 조회 2,119
14년 전 조회 2,279
14년 전 조회 1,823
14년 전 조회 1,868
14년 전 조회 3,106
14년 전 조회 1,897
14년 전 조회 3,389
14년 전 조회 1,629
14년 전 조회 4,492
14년 전 조회 1,682
14년 전 조회 3,081
14년 전 조회 4,467
14년 전 조회 1,721
14년 전 조회 1,914
14년 전 조회 2,273
14년 전 조회 1,817
14년 전 조회 2,355
14년 전 조회 2,229
14년 전 조회 2,354
14년 전 조회 2,106
14년 전 조회 1,706
14년 전 조회 2,162
14년 전 조회 2,160
14년 전 조회 2,035
14년 전 조회 1,602
14년 전 조회 1,553
14년 전 조회 1,974
14년 전 조회 1,469
14년 전 조회 4,050
14년 전 조회 1,491
14년 전 조회 1,887
14년 전 조회 1,545
14년 전 조회 1,564
14년 전 조회 2,812
14년 전 조회 1,866
14년 전 조회 2,301
14년 전 조회 1,603
14년 전 조회 2,166
14년 전 조회 2,674
14년 전 조회 1,749
14년 전 조회 2,218
14년 전 조회 1,738
14년 전 조회 2,104
14년 전 조회 3,564
14년 전 조회 1,599
14년 전 조회 5,746
14년 전 조회 1,606
14년 전 조회 1,772
14년 전 조회 1,624
14년 전 조회 4,322
14년 전 조회 1,421
14년 전 조회 1,748
14년 전 조회 2,066
14년 전 조회 2,074
14년 전 조회 1,550
14년 전 조회 2,172
14년 전 조회 1,636
14년 전 조회 1,517
14년 전 조회 3,176
14년 전 조회 1,910
14년 전 조회 1,503
14년 전 조회 1,476
14년 전 조회 2,526
14년 전 조회 1,682
14년 전 조회 2,095
14년 전 조회 2,075
14년 전 조회 2,686
14년 전 조회 2,758
14년 전 조회 2,029
14년 전 조회 1,674
14년 전 조회 1,588
14년 전 조회 1,804
14년 전 조회 1,999
14년 전 조회 3,453
14년 전 조회 1,477