v

PHP ANOTATION , Reflection

· 14년 전 · 1631
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,364
14년 전 조회 2,601
14년 전 조회 2,152
14년 전 조회 3,158
14년 전 조회 1,821
14년 전 조회 1,840
14년 전 조회 1,658
14년 전 조회 2,453
14년 전 조회 2,092
14년 전 조회 1,784
14년 전 조회 6,328
14년 전 조회 2,937
14년 전 조회 2,190
14년 전 조회 1,686
14년 전 조회 1만
14년 전 조회 2,596
14년 전 조회 1,619
14년 전 조회 1,640
14년 전 조회 2,482
14년 전 조회 3,031
14년 전 조회 2,550
14년 전 조회 1,792
14년 전 조회 3,078
14년 전 조회 3,029
14년 전 조회 4,043
14년 전 조회 2,149
14년 전 조회 2,308
14년 전 조회 1,844
14년 전 조회 1,897
14년 전 조회 3,137
14년 전 조회 1,926
14년 전 조회 3,416
14년 전 조회 1,653
14년 전 조회 4,520
14년 전 조회 1,699
14년 전 조회 3,117
14년 전 조회 4,491
14년 전 조회 1,751
14년 전 조회 1,941
14년 전 조회 2,295
14년 전 조회 1,844
14년 전 조회 2,381
14년 전 조회 2,252
14년 전 조회 2,385
14년 전 조회 2,133
14년 전 조회 1,734
14년 전 조회 2,185
14년 전 조회 2,188
14년 전 조회 2,069
14년 전 조회 1,632
14년 전 조회 1,585
14년 전 조회 2,001
14년 전 조회 1,495
14년 전 조회 4,080
14년 전 조회 1,524
14년 전 조회 1,918
14년 전 조회 1,570
14년 전 조회 1,594
14년 전 조회 2,845
14년 전 조회 1,895
14년 전 조회 2,337
14년 전 조회 1,630
14년 전 조회 2,197
14년 전 조회 2,706
14년 전 조회 1,775
14년 전 조회 2,245
14년 전 조회 1,770
14년 전 조회 2,131
14년 전 조회 3,594
14년 전 조회 1,624
14년 전 조회 5,771
14년 전 조회 1,634
14년 전 조회 1,808
14년 전 조회 1,656
14년 전 조회 4,364
14년 전 조회 1,449
14년 전 조회 1,779
14년 전 조회 2,092
14년 전 조회 2,106
14년 전 조회 1,571
14년 전 조회 2,208
14년 전 조회 1,659
14년 전 조회 1,548
14년 전 조회 3,211
14년 전 조회 1,934
14년 전 조회 1,525
14년 전 조회 1,504
14년 전 조회 2,558
14년 전 조회 1,706
14년 전 조회 2,123
14년 전 조회 2,100
14년 전 조회 2,714
14년 전 조회 2,786
14년 전 조회 2,056
14년 전 조회 1,699
14년 전 조회 1,622
14년 전 조회 1,839
14년 전 조회 2,029
14년 전 조회 3,483
14년 전 조회 1,508