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,291
14년 전 조회 1,542
14년 전 조회 1,107
14년 전 조회 2,099
14년 전 조회 775
14년 전 조회 793
14년 전 조회 617
14년 전 조회 1,418
14년 전 조회 1,033
14년 전 조회 756
14년 전 조회 5,285
14년 전 조회 1,899
14년 전 조회 1,137
14년 전 조회 632
14년 전 조회 9,428
14년 전 조회 1,544
14년 전 조회 561
14년 전 조회 545
14년 전 조회 1,414
14년 전 조회 1,989
14년 전 조회 1,542
14년 전 조회 789
14년 전 조회 2,038
14년 전 조회 2,042
14년 전 조회 2,996
14년 전 조회 1,096
14년 전 조회 1,285
14년 전 조회 800
14년 전 조회 893
14년 전 조회 2,111
14년 전 조회 902
14년 전 조회 2,375
14년 전 조회 617
14년 전 조회 3,489
14년 전 조회 710
14년 전 조회 2,061
14년 전 조회 3,449
14년 전 조회 757
14년 전 조회 939
14년 전 조회 1,298
14년 전 조회 793
14년 전 조회 1,301
14년 전 조회 1,230
14년 전 조회 1,342
14년 전 조회 1,090
14년 전 조회 720
14년 전 조회 1,193
14년 전 조회 1,165
14년 전 조회 1,043
14년 전 조회 600
14년 전 조회 580
14년 전 조회 928
14년 전 조회 494
14년 전 조회 3,059
14년 전 조회 572
14년 전 조회 935
14년 전 조회 586
14년 전 조회 615
14년 전 조회 1,848
14년 전 조회 904
14년 전 조회 1,384
14년 전 조회 642
14년 전 조회 1,274
14년 전 조회 1,751
14년 전 조회 793
14년 전 조회 1,311
14년 전 조회 806
14년 전 조회 1,173
14년 전 조회 2,597
14년 전 조회 656
14년 전 조회 4,779
14년 전 조회 671
14년 전 조회 857
14년 전 조회 699
14년 전 조회 3,387
14년 전 조회 501
14년 전 조회 833
14년 전 조회 1,129
14년 전 조회 1,129
14년 전 조회 623
14년 전 조회 1,226
14년 전 조회 709
14년 전 조회 597
14년 전 조회 2,251
14년 전 조회 948
14년 전 조회 572
14년 전 조회 573
14년 전 조회 1,602
14년 전 조회 751
14년 전 조회 1,160
14년 전 조회 1,151
14년 전 조회 1,756
14년 전 조회 1,830
14년 전 조회 1,103
14년 전 조회 762
14년 전 조회 696
14년 전 조회 942
14년 전 조회 1,098
14년 전 조회 2,509
14년 전 조회 570
🐛 버그신고