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,296
14년 전 조회 1,545
14년 전 조회 1,113
14년 전 조회 2,101
14년 전 조회 782
14년 전 조회 798
14년 전 조회 621
14년 전 조회 1,422
14년 전 조회 1,037
14년 전 조회 759
14년 전 조회 5,290
14년 전 조회 1,905
14년 전 조회 1,140
14년 전 조회 642
14년 전 조회 9,435
14년 전 조회 1,548
14년 전 조회 570
14년 전 조회 548
14년 전 조회 1,417
14년 전 조회 1,996
14년 전 조회 1,545
14년 전 조회 795
14년 전 조회 2,044
14년 전 조회 2,050
14년 전 조회 2,998
14년 전 조회 1,100
14년 전 조회 1,291
14년 전 조회 807
14년 전 조회 894
14년 전 조회 2,117
14년 전 조회 908
14년 전 조회 2,377
14년 전 조회 622
14년 전 조회 3,492
14년 전 조회 714
14년 전 조회 2,064
14년 전 조회 3,452
14년 전 조회 765
14년 전 조회 942
14년 전 조회 1,302
14년 전 조회 800
14년 전 조회 1,306
14년 전 조회 1,234
14년 전 조회 1,345
14년 전 조회 1,092
14년 전 조회 727
14년 전 조회 1,196
14년 전 조회 1,172
14년 전 조회 1,048
14년 전 조회 608
14년 전 조회 585
14년 전 조회 934
14년 전 조회 498
14년 전 조회 3,063
14년 전 조회 576
14년 전 조회 939
14년 전 조회 592
14년 전 조회 622
14년 전 조회 1,854
14년 전 조회 909
14년 전 조회 1,390
14년 전 조회 649
14년 전 조회 1,282
14년 전 조회 1,758
14년 전 조회 804
14년 전 조회 1,319
14년 전 조회 815
14년 전 조회 1,179
14년 전 조회 2,603
14년 전 조회 662
14년 전 조회 4,787
14년 전 조회 677
14년 전 조회 863
14년 전 조회 708
14년 전 조회 3,398
14년 전 조회 508
14년 전 조회 842
14년 전 조회 1,140
14년 전 조회 1,137
14년 전 조회 630
14년 전 조회 1,234
14년 전 조회 713
14년 전 조회 604
14년 전 조회 2,254
14년 전 조회 954
14년 전 조회 581
14년 전 조회 581
14년 전 조회 1,608
14년 전 조회 759
14년 전 조회 1,163
14년 전 조회 1,154
14년 전 조회 1,759
14년 전 조회 1,836
14년 전 조회 1,108
14년 전 조회 772
14년 전 조회 703
14년 전 조회 948
14년 전 조회 1,108
14년 전 조회 2,518
14년 전 조회 579
🐛 버그신고