v

PHP ANOTATION , Reflection

· 14년 전 · 1739
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,490
14년 전 조회 2,712
14년 전 조회 2,255
14년 전 조회 3,261
14년 전 조회 1,931
14년 전 조회 1,960
14년 전 조회 1,765
14년 전 조회 2,553
14년 전 조회 2,198
14년 전 조회 1,908
14년 전 조회 6,448
14년 전 조회 3,047
14년 전 조회 2,309
14년 전 조회 1,801
14년 전 조회 1.1만
14년 전 조회 2,713
14년 전 조회 1,718
14년 전 조회 1,762
14년 전 조회 2,596
14년 전 조회 3,150
14년 전 조회 2,679
14년 전 조회 1,902
14년 전 조회 3,212
14년 전 조회 3,150
14년 전 조회 4,149
14년 전 조회 2,260
14년 전 조회 2,415
14년 전 조회 1,950
14년 전 조회 2,008
14년 전 조회 3,258
14년 전 조회 2,037
14년 전 조회 3,549
14년 전 조회 1,770
14년 전 조회 4,633
14년 전 조회 1,813
14년 전 조회 3,216
14년 전 조회 4,603
14년 전 조회 1,845
14년 전 조회 2,051
14년 전 조회 2,406
14년 전 조회 1,940
14년 전 조회 2,489
14년 전 조회 2,356
14년 전 조회 2,498
14년 전 조회 2,234
14년 전 조회 1,820
14년 전 조회 2,280
14년 전 조회 2,286
14년 전 조회 2,176
14년 전 조회 1,740
14년 전 조회 1,677
14년 전 조회 2,099
14년 전 조회 1,621
14년 전 조회 4,168
14년 전 조회 1,637
14년 전 조회 2,006
14년 전 조회 1,673
14년 전 조회 1,704
14년 전 조회 2,924
14년 전 조회 1,991
14년 전 조회 2,442
14년 전 조회 1,712
14년 전 조회 2,283
14년 전 조회 2,799
14년 전 조회 1,862
14년 전 조회 2,336
14년 전 조회 1,850
14년 전 조회 2,228
14년 전 조회 3,692
14년 전 조회 1,705
14년 전 조회 5,851
14년 전 조회 1,721
14년 전 조회 1,890
14년 전 조회 1,731
14년 전 조회 4,463
14년 전 조회 1,534
14년 전 조회 1,864
14년 전 조회 2,180
14년 전 조회 2,190
14년 전 조회 1,660
14년 전 조회 2,291
14년 전 조회 1,743
14년 전 조회 1,630
14년 전 조회 3,308
14년 전 조회 2,023
14년 전 조회 1,611
14년 전 조회 1,600
14년 전 조회 2,640
14년 전 조회 1,807
14년 전 조회 2,209
14년 전 조회 2,198
14년 전 조회 2,801
14년 전 조회 2,881
14년 전 조회 2,150
14년 전 조회 1,779
14년 전 조회 1,703
14년 전 조회 1,932
14년 전 조회 2,109
14년 전 조회 3,589
14년 전 조회 1,609