v

PHP ANOTATION , Reflection

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,492
14년 전 조회 1,749
14년 전 조회 1,290
14년 전 조회 2,333
14년 전 조회 974
14년 전 조회 967
14년 전 조회 817
14년 전 조회 1,619
14년 전 조회 1,231
14년 전 조회 966
14년 전 조회 5,510
14년 전 조회 2,108
14년 전 조회 1,356
14년 전 조회 817
14년 전 조회 9,617
14년 전 조회 1,733
14년 전 조회 758
14년 전 조회 744
14년 전 조회 1,659
14년 전 조회 2,179
14년 전 조회 1,709
14년 전 조회 983
14년 전 조회 2,257
14년 전 조회 2,267
14년 전 조회 3,216
14년 전 조회 1,304
14년 전 조회 1,458
14년 전 조회 993
14년 전 조회 1,087
14년 전 조회 2,331
14년 전 조회 1,101
14년 전 조회 2,580
14년 전 조회 802
14년 전 조회 3,681
14년 전 조회 901
14년 전 조회 2,254
14년 전 조회 3,650
14년 전 조회 936
14년 전 조회 1,131
14년 전 조회 1,501
14년 전 조회 989
14년 전 조회 1,524
14년 전 조회 1,420
14년 전 조회 1,523
14년 전 조회 1,299
14년 전 조회 904
14년 전 조회 1,374
14년 전 조회 1,374
14년 전 조회 1,232
14년 전 조회 810
14년 전 조회 757
14년 전 조회 1,147
14년 전 조회 690
14년 전 조회 3,254
14년 전 조회 771
14년 전 조회 1,131
14년 전 조회 777
14년 전 조회 834
14년 전 조회 2,065
14년 전 조회 1,086
14년 전 조회 1,605
14년 전 조회 842
14년 전 조회 1,439
14년 전 조회 1,930
14년 전 조회 990
14년 전 조회 1,493
14년 전 조회 998
14년 전 조회 1,382
14년 전 조회 2,797
14년 전 조회 861
14년 전 조회 5,018
14년 전 조회 852
14년 전 조회 1,039
14년 전 조회 872
14년 전 조회 3,610
14년 전 조회 673
14년 전 조회 1,037
14년 전 조회 1,319
14년 전 조회 1,319
14년 전 조회 795
14년 전 조회 1,425
14년 전 조회 895
14년 전 조회 770
14년 전 조회 2,440
14년 전 조회 1,149
14년 전 조회 765
14년 전 조회 742
14년 전 조회 1,785
14년 전 조회 958
14년 전 조회 1,344
14년 전 조회 1,325
14년 전 조회 1,978
14년 전 조회 2,016
14년 전 조회 1,296
14년 전 조회 935
14년 전 조회 870
14년 전 조회 1,102
14년 전 조회 1,295
14년 전 조회 2,754
14년 전 조회 752