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,311
14년 전 조회 1,569
14년 전 조회 1,127
14년 전 조회 2,124
14년 전 조회 800
14년 전 조회 807
14년 전 조회 641
14년 전 조회 1,441
14년 전 조회 1,055
14년 전 조회 777
14년 전 조회 5,302
14년 전 조회 1,927
14년 전 조회 1,155
14년 전 조회 654
14년 전 조회 9,453
14년 전 조회 1,565
14년 전 조회 586
14년 전 조회 570
14년 전 조회 1,435
14년 전 조회 2,011
14년 전 조회 1,559
14년 전 조회 817
14년 전 조회 2,061
14년 전 조회 2,067
14년 전 조회 3,011
14년 전 조회 1,112
14년 전 조회 1,306
14년 전 조회 825
14년 전 조회 912
14년 전 조회 2,137
14년 전 조회 928
14년 전 조회 2,395
14년 전 조회 639
14년 전 조회 3,507
14년 전 조회 729
14년 전 조회 2,089
14년 전 조회 3,470
14년 전 조회 780
14년 전 조회 950
14년 전 조회 1,315
14년 전 조회 813
14년 전 조회 1,329
14년 전 조회 1,247
14년 전 조회 1,362
14년 전 조회 1,105
14년 전 조회 741
14년 전 조회 1,207
14년 전 조회 1,192
14년 전 조회 1,065
14년 전 조회 622
14년 전 조회 607
14년 전 조회 948
14년 전 조회 513
14년 전 조회 3,084
14년 전 조회 594
14년 전 조회 957
14년 전 조회 608
14년 전 조회 642
14년 전 조회 1,871
14년 전 조회 924
14년 전 조회 1,405
14년 전 조회 666
14년 전 조회 1,297
14년 전 조회 1,777
14년 전 조회 825
14년 전 조회 1,333
14년 전 조회 829
14년 전 조회 1,194
14년 전 조회 2,622
14년 전 조회 687
14년 전 조회 4,802
14년 전 조회 694
14년 전 조회 884
14년 전 조회 725
14년 전 조회 3,417
14년 전 조회 526
14년 전 조회 861
14년 전 조회 1,154
14년 전 조회 1,154
14년 전 조회 645
14년 전 조회 1,251
14년 전 조회 727
14년 전 조회 618
14년 전 조회 2,274
14년 전 조회 970
14년 전 조회 599
14년 전 조회 596
14년 전 조회 1,622
14년 전 조회 773
14년 전 조회 1,182
14년 전 조회 1,164
14년 전 조회 1,776
14년 전 조회 1,849
14년 전 조회 1,126
14년 전 조회 790
14년 전 조회 722
14년 전 조회 967
14년 전 조회 1,121
14년 전 조회 2,534
14년 전 조회 595
🐛 버그신고