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,305
14년 전 조회 1,566
14년 전 조회 1,124
14년 전 조회 2,122
14년 전 조회 796
14년 전 조회 804
14년 전 조회 638
14년 전 조회 1,438
14년 전 조회 1,052
14년 전 조회 772
14년 전 조회 5,298
14년 전 조회 1,921
14년 전 조회 1,151
14년 전 조회 649
14년 전 조회 9,447
14년 전 조회 1,562
14년 전 조회 583
14년 전 조회 566
14년 전 조회 1,431
14년 전 조회 2,010
14년 전 조회 1,557
14년 전 조회 812
14년 전 조회 2,053
14년 전 조회 2,063
14년 전 조회 3,006
14년 전 조회 1,112
14년 전 조회 1,303
14년 전 조회 821
14년 전 조회 908
14년 전 조회 2,133
14년 전 조회 922
14년 전 조회 2,389
14년 전 조회 635
14년 전 조회 3,504
14년 전 조회 725
14년 전 조회 2,080
14년 전 조회 3,466
14년 전 조회 775
14년 전 조회 948
14년 전 조회 1,312
14년 전 조회 810
14년 전 조회 1,325
14년 전 조회 1,244
14년 전 조회 1,357
14년 전 조회 1,101
14년 전 조회 738
14년 전 조회 1,204
14년 전 조회 1,187
14년 전 조회 1,062
14년 전 조회 619
14년 전 조회 598
14년 전 조회 944
14년 전 조회 512
14년 전 조회 3,078
14년 전 조회 590
14년 전 조회 954
14년 전 조회 606
14년 전 조회 632
14년 전 조회 1,866
14년 전 조회 922
14년 전 조회 1,401
14년 전 조회 663
14년 전 조회 1,293
14년 전 조회 1,773
14년 전 조회 819
14년 전 조회 1,330
14년 전 조회 827
14년 전 조회 1,190
14년 전 조회 2,619
14년 전 조회 679
14년 전 조회 4,799
14년 전 조회 690
14년 전 조회 879
14년 전 조회 721
14년 전 조회 3,413
14년 전 조회 522
14년 전 조회 856
14년 전 조회 1,151
14년 전 조회 1,151
14년 전 조회 643
14년 전 조회 1,246
14년 전 조회 724
14년 전 조회 617
14년 전 조회 2,270
14년 전 조회 963
14년 전 조회 593
14년 전 조회 593
14년 전 조회 1,619
14년 전 조회 770
14년 전 조회 1,176
14년 전 조회 1,162
14년 전 조회 1,772
14년 전 조회 1,847
14년 전 조회 1,124
14년 전 조회 788
14년 전 조회 717
14년 전 조회 965
14년 전 조회 1,119
14년 전 조회 2,530
14년 전 조회 591
🐛 버그신고