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,293
14년 전 조회 1,543
14년 전 조회 1,108
14년 전 조회 2,101
14년 전 조회 780
14년 전 조회 795
14년 전 조회 621
14년 전 조회 1,420
14년 전 조회 1,035
14년 전 조회 758
14년 전 조회 5,287
14년 전 조회 1,902
14년 전 조회 1,138
14년 전 조회 636
14년 전 조회 9,431
14년 전 조회 1,545
14년 전 조회 564
14년 전 조회 546
14년 전 조회 1,415
14년 전 조회 1,992
14년 전 조회 1,543
14년 전 조회 793
14년 전 조회 2,042
14년 전 조회 2,047
14년 전 조회 2,996
14년 전 조회 1,098
14년 전 조회 1,288
14년 전 조회 805
14년 전 조회 893
14년 전 조회 2,114
14년 전 조회 902
14년 전 조회 2,376
14년 전 조회 620
14년 전 조회 3,490
14년 전 조회 712
14년 전 조회 2,063
14년 전 조회 3,451
14년 전 조회 761
14년 전 조회 939
14년 전 조회 1,299
14년 전 조회 798
14년 전 조회 1,303
14년 전 조회 1,233
14년 전 조회 1,344
14년 전 조회 1,092
14년 전 조회 725
14년 전 조회 1,194
14년 전 조회 1,170
14년 전 조회 1,046
14년 전 조회 603
14년 전 조회 584
14년 전 조회 933
14년 전 조회 496
14년 전 조회 3,062
14년 전 조회 573
14년 전 조회 937
14년 전 조회 590
14년 전 조회 617
14년 전 조회 1,851
14년 전 조회 907
14년 전 조회 1,388
14년 전 조회 646
14년 전 조회 1,278
14년 전 조회 1,754
14년 전 조회 800
14년 전 조회 1,318
14년 전 조회 812
14년 전 조회 1,179
14년 전 조회 2,599
14년 전 조회 660
14년 전 조회 4,784
14년 전 조회 674
14년 전 조회 860
14년 전 조회 707
14년 전 조회 3,394
14년 전 조회 507
14년 전 조회 839
14년 전 조회 1,134
14년 전 조회 1,134
14년 전 조회 629
14년 전 조회 1,231
14년 전 조회 711
14년 전 조회 601
14년 전 조회 2,254
14년 전 조회 952
14년 전 조회 577
14년 전 조회 578
14년 전 조회 1,605
14년 전 조회 756
14년 전 조회 1,161
14년 전 조회 1,154
14년 전 조회 1,757
14년 전 조회 1,833
14년 전 조회 1,105
14년 전 조회 770
14년 전 조회 702
14년 전 조회 948
14년 전 조회 1,102
14년 전 조회 2,516
14년 전 조회 576
🐛 버그신고