v

PHP ANOTATION , Reflection

· 14년 전 · 1174
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년 전 조회 1,868
14년 전 조회 2,128
14년 전 조회 1,648
14년 전 조회 2,694
14년 전 조회 1,316
14년 전 조회 1,322
14년 전 조회 1,176
14년 전 조회 1,988
14년 전 조회 1,609
14년 전 조회 1,319
14년 전 조회 5,935
14년 전 조회 2,459
14년 전 조회 1,759
14년 전 조회 1,189
14년 전 조회 9,951
14년 전 조회 2,125
14년 전 조회 1,109
14년 전 조회 1,120
14년 전 조회 2,066
14년 전 조회 2,540
14년 전 조회 2,081
14년 전 조회 1,318
14년 전 조회 2,617
14년 전 조회 2,600
14년 전 조회 3,606
14년 전 조회 1,687
14년 전 조회 1,801
14년 전 조회 1,333
14년 전 조회 1,448
14년 전 조회 2,695
14년 전 조회 1,448
14년 전 조회 2,965
14년 전 조회 1,163
14년 전 조회 4,031
14년 전 조회 1,255
14년 전 조회 2,607
14년 전 조회 4,005
14년 전 조회 1,285
14년 전 조회 1,458
14년 전 조회 1,845
14년 전 조회 1,339
14년 전 조회 1,870
14년 전 조회 1,774
14년 전 조회 1,875
14년 전 조회 1,701
14년 전 조회 1,234
14년 전 조회 1,721
14년 전 조회 1,734
14년 전 조회 1,595
14년 전 조회 1,175
14년 전 조회 1,092
14년 전 조회 1,558
14년 전 조회 1,024
14년 전 조회 3,601
14년 전 조회 1,049
14년 전 조회 1,442
14년 전 조회 1,087
14년 전 조회 1,130
14년 전 조회 2,363
14년 전 조회 1,412
14년 전 조회 1,893
14년 전 조회 1,156
14년 전 조회 1,730
14년 전 조회 2,255
14년 전 조회 1,299
14년 전 조회 1,776
14년 전 조회 1,305
14년 전 조회 1,673
14년 전 조회 3,105
14년 전 조회 1,150
14년 전 조회 5,383
14년 전 조회 1,160
14년 전 조회 1,337
14년 전 조회 1,174
14년 전 조회 3,894
14년 전 조회 969
14년 전 조회 1,318
14년 전 조회 1,607
14년 전 조회 1,627
14년 전 조회 1,097
14년 전 조회 1,722
14년 전 조회 1,185
14년 전 조회 1,059
14년 전 조회 2,738
14년 전 조회 1,466
14년 전 조회 1,072
14년 전 조회 1,041
14년 전 조회 2,100
14년 전 조회 1,261
14년 전 조회 1,670
14년 전 조회 1,645
14년 전 조회 2,311
14년 전 조회 2,316
14년 전 조회 1,590
14년 전 조회 1,216
14년 전 조회 1,179
14년 전 조회 1,390
14년 전 조회 1,568
14년 전 조회 3,107
14년 전 조회 1,041