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,425
14년 전 조회 1,673
14년 전 조회 1,238
14년 전 조회 2,243
14년 전 조회 901
14년 전 조회 918
14년 전 조회 746
14년 전 조회 1,553
14년 전 조회 1,177
14년 전 조회 893
14년 전 조회 5,418
14년 전 조회 2,021
14년 전 조회 1,267
14년 전 조회 750
14년 전 조회 9,548
14년 전 조회 1,672
14년 전 조회 695
14년 전 조회 688
14년 전 조회 1,551
14년 전 조회 2,124
14년 전 조회 1,665
14년 전 조회 913
14년 전 조회 2,164
14년 전 조회 2,177
14년 전 조회 3,117
14년 전 조회 1,228
14년 전 조회 1,395
14년 전 조회 933
14년 전 조회 1,023
14년 전 조회 2,250
14년 전 조회 1,043
14년 전 조회 2,508
14년 전 조회 737
14년 전 조회 3,611
14년 전 조회 839
14년 전 조회 2,200
14년 전 조회 3,595
14년 전 조회 883
14년 전 조회 1,060
14년 전 조회 1,424
14년 전 조회 927
14년 전 조회 1,451
14년 전 조회 1,360
14년 전 조회 1,483
14년 전 조회 1,212
14년 전 조회 845
14년 전 조회 1,314
14년 전 조회 1,296
14년 전 조회 1,179
14년 전 조회 736
14년 전 조회 699
14년 전 조회 1,056
14년 전 조회 629
14년 전 조회 3,197
14년 전 조회 707
14년 전 조회 1,071
14년 전 조회 726
14년 전 조회 742
14년 전 조회 1,988
14년 전 조회 1,019
14년 전 조회 1,518
14년 전 조회 776
14년 전 조회 1,385
14년 전 조회 1,891
14년 전 조회 925
14년 전 조회 1,422
14년 전 조회 944
14년 전 조회 1,301
14년 전 조회 2,731
14년 전 조회 804
14년 전 조회 4,908
14년 전 조회 797
14년 전 조회 976
14년 전 조회 817
14년 전 조회 3,524
14년 전 조회 616
14년 전 조회 962
14년 전 조회 1,256
14년 전 조회 1,264
14년 전 조회 749
14년 전 조회 1,364
14년 전 조회 847
14년 전 조회 719
14년 전 조회 2,391
14년 전 조회 1,079
14년 전 조회 706
14년 전 조회 688
14년 전 조회 1,724
14년 전 조회 877
14년 전 조회 1,298
14년 전 조회 1,266
14년 전 조회 1,884
14년 전 조회 1,971
14년 전 조회 1,241
14년 전 조회 882
14년 전 조회 812
14년 전 조회 1,058
14년 전 조회 1,227
14년 전 조회 2,655
14년 전 조회 699