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,312
14년 전 조회 1,573
14년 전 조회 1,129
14년 전 조회 2,127
14년 전 조회 802
14년 전 조회 813
14년 전 조회 646
14년 전 조회 1,442
14년 전 조회 1,059
14년 전 조회 781
14년 전 조회 5,304
14년 전 조회 1,931
14년 전 조회 1,156
14년 전 조회 657
14년 전 조회 9,456
14년 전 조회 1,568
14년 전 조회 587
14년 전 조회 572
14년 전 조회 1,438
14년 전 조회 2,011
14년 전 조회 1,564
14년 전 조회 818
14년 전 조회 2,063
14년 전 조회 2,071
14년 전 조회 3,014
14년 전 조회 1,114
14년 전 조회 1,308
14년 전 조회 830
14년 전 조회 914
14년 전 조회 2,139
14년 전 조회 932
14년 전 조회 2,398
14년 전 조회 641
14년 전 조회 3,509
14년 전 조회 730
14년 전 조회 2,089
14년 전 조회 3,471
14년 전 조회 781
14년 전 조회 952
14년 전 조회 1,315
14년 전 조회 815
14년 전 조회 1,330
14년 전 조회 1,249
14년 전 조회 1,365
14년 전 조회 1,105
14년 전 조회 742
14년 전 조회 1,209
14년 전 조회 1,193
14년 전 조회 1,068
14년 전 조회 625
14년 전 조회 607
14년 전 조회 952
14년 전 조회 515
14년 전 조회 3,086
14년 전 조회 598
14년 전 조회 962
14년 전 조회 612
14년 전 조회 645
14년 전 조회 1,874
14년 전 조회 927
14년 전 조회 1,407
14년 전 조회 669
14년 전 조회 1,300
14년 전 조회 1,779
14년 전 조회 828
14년 전 조회 1,337
14년 전 조회 831
14년 전 조회 1,196
14년 전 조회 2,625
14년 전 조회 691
14년 전 조회 4,807
14년 전 조회 695
14년 전 조회 886
14년 전 조회 726
14년 전 조회 3,418
14년 전 조회 529
14년 전 조회 862
14년 전 조회 1,159
14년 전 조회 1,155
14년 전 조회 647
14년 전 조회 1,253
14년 전 조회 728
14년 전 조회 619
14년 전 조회 2,275
14년 전 조회 973
14년 전 조회 601
14년 전 조회 599
14년 전 조회 1,624
14년 전 조회 775
14년 전 조회 1,184
14년 전 조회 1,165
14년 전 조회 1,778
14년 전 조회 1,852
14년 전 조회 1,128
14년 전 조회 791
14년 전 조회 724
14년 전 조회 969
14년 전 조회 1,126
14년 전 조회 2,537
14년 전 조회 597
🐛 버그신고