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,298
14년 전 조회 1,548
14년 전 조회 1,114
14년 전 조회 2,105
14년 전 조회 787
14년 전 조회 800
14년 전 조회 623
14년 전 조회 1,426
14년 전 조회 1,041
14년 전 조회 762
14년 전 조회 5,293
14년 전 조회 1,908
14년 전 조회 1,143
14년 전 조회 644
14년 전 조회 9,437
14년 전 조회 1,551
14년 전 조회 571
14년 전 조회 553
14년 전 조회 1,421
14년 전 조회 1,999
14년 전 조회 1,547
14년 전 조회 798
14년 전 조회 2,048
14년 전 조회 2,054
14년 전 조회 3,002
14년 전 조회 1,104
14년 전 조회 1,292
14년 전 조회 810
14년 전 조회 897
14년 전 조회 2,121
14년 전 조회 910
14년 전 조회 2,382
14년 전 조회 624
14년 전 조회 3,495
14년 전 조회 718
14년 전 조회 2,069
14년 전 조회 3,458
14년 전 조회 767
14년 전 조회 945
14년 전 조회 1,306
14년 전 조회 803
14년 전 조회 1,310
14년 전 조회 1,239
14년 전 조회 1,350
14년 전 조회 1,097
14년 전 조회 729
14년 전 조회 1,199
14년 전 조회 1,177
14년 전 조회 1,053
14년 전 조회 610
14년 전 조회 590
14년 전 조회 937
14년 전 조회 500
14년 전 조회 3,067
14년 전 조회 581
14년 전 조회 944
14년 전 조회 594
14년 전 조회 624
14년 전 조회 1,860
14년 전 조회 911
14년 전 조회 1,393
14년 전 조회 650
14년 전 조회 1,284
14년 전 조회 1,761
14년 전 조회 807
14년 전 조회 1,322
14년 전 조회 819
14년 전 조회 1,184
14년 전 조회 2,608
14년 전 조회 667
14년 전 조회 4,792
14년 전 조회 678
14년 전 조회 863
14년 전 조회 711
14년 전 조회 3,402
14년 전 조회 512
14년 전 조회 846
14년 전 조회 1,142
14년 전 조회 1,140
14년 전 조회 632
14년 전 조회 1,237
14년 전 조회 717
14년 전 조회 608
14년 전 조회 2,259
14년 전 조회 957
14년 전 조회 585
14년 전 조회 583
14년 전 조회 1,614
14년 전 조회 765
14년 전 조회 1,168
14년 전 조회 1,159
14년 전 조회 1,764
14년 전 조회 1,840
14년 전 조회 1,112
14년 전 조회 774
14년 전 조회 709
14년 전 조회 954
14년 전 조회 1,111
14년 전 조회 2,522
14년 전 조회 584
🐛 버그신고