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,295
14년 전 조회 1,544
14년 전 조회 1,112
14년 전 조회 2,101
14년 전 조회 782
14년 전 조회 798
14년 전 조회 621
14년 전 조회 1,421
14년 전 조회 1,036
14년 전 조회 759
14년 전 조회 5,290
14년 전 조회 1,905
14년 전 조회 1,140
14년 전 조회 641
14년 전 조회 9,435
14년 전 조회 1,547
14년 전 조회 569
14년 전 조회 547
14년 전 조회 1,416
14년 전 조회 1,996
14년 전 조회 1,545
14년 전 조회 795
14년 전 조회 2,043
14년 전 조회 2,050
14년 전 조회 2,998
14년 전 조회 1,099
14년 전 조회 1,291
14년 전 조회 807
14년 전 조회 893
14년 전 조회 2,117
14년 전 조회 907
14년 전 조회 2,376
14년 전 조회 622
14년 전 조회 3,491
14년 전 조회 713
14년 전 조회 2,064
14년 전 조회 3,451
14년 전 조회 765
14년 전 조회 942
14년 전 조회 1,301
14년 전 조회 800
14년 전 조회 1,306
14년 전 조회 1,234
14년 전 조회 1,344
14년 전 조회 1,092
14년 전 조회 727
14년 전 조회 1,196
14년 전 조회 1,172
14년 전 조회 1,048
14년 전 조회 607
14년 전 조회 585
14년 전 조회 934
14년 전 조회 498
14년 전 조회 3,063
14년 전 조회 576
14년 전 조회 939
14년 전 조회 592
14년 전 조회 621
14년 전 조회 1,853
14년 전 조회 909
14년 전 조회 1,389
14년 전 조회 648
14년 전 조회 1,281
14년 전 조회 1,757
14년 전 조회 803
14년 전 조회 1,318
14년 전 조회 814
14년 전 조회 1,179
14년 전 조회 2,603
14년 전 조회 662
14년 전 조회 4,787
14년 전 조회 676
14년 전 조회 863
14년 전 조회 708
14년 전 조회 3,398
14년 전 조회 507
14년 전 조회 842
14년 전 조회 1,139
14년 전 조회 1,135
14년 전 조회 630
14년 전 조회 1,234
14년 전 조회 712
14년 전 조회 604
14년 전 조회 2,254
14년 전 조회 954
14년 전 조회 581
14년 전 조회 581
14년 전 조회 1,608
14년 전 조회 759
14년 전 조회 1,162
14년 전 조회 1,154
14년 전 조회 1,759
14년 전 조회 1,835
14년 전 조회 1,107
14년 전 조회 771
14년 전 조회 703
14년 전 조회 948
14년 전 조회 1,108
14년 전 조회 2,518
14년 전 조회 578
🐛 버그신고