v

PHP ANOTATION , Reflection

· 14년 전 · 1579
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년 전 조회 2,317
14년 전 조회 2,556
14년 전 조회 2,094
14년 전 조회 3,105
14년 전 조회 1,759
14년 전 조회 1,781
14년 전 조회 1,605
14년 전 조회 2,409
14년 전 조회 2,032
14년 전 조회 1,740
14년 전 조회 6,290
14년 전 조회 2,878
14년 전 조회 2,139
14년 전 조회 1,638
14년 전 조회 1만
14년 전 조회 2,539
14년 전 조회 1,565
14년 전 조회 1,568
14년 전 조회 2,427
14년 전 조회 2,977
14년 전 조회 2,493
14년 전 조회 1,737
14년 전 조회 3,030
14년 전 조회 2,973
14년 전 조회 3,992
14년 전 조회 2,095
14년 전 조회 2,260
14년 전 조회 1,798
14년 전 조회 1,841
14년 전 조회 3,080
14년 전 조회 1,882
14년 전 조회 3,365
14년 전 조회 1,601
14년 전 조회 4,474
14년 전 조회 1,655
14년 전 조회 3,053
14년 전 조회 4,443
14년 전 조회 1,701
14년 전 조회 1,893
14년 전 조회 2,246
14년 전 조회 1,792
14년 전 조회 2,332
14년 전 조회 2,199
14년 전 조회 2,324
14년 전 조회 2,084
14년 전 조회 1,680
14년 전 조회 2,137
14년 전 조회 2,130
14년 전 조회 2,006
14년 전 조회 1,580
14년 전 조회 1,531
14년 전 조회 1,947
14년 전 조회 1,448
14년 전 조회 4,022
14년 전 조회 1,457
14년 전 조회 1,863
14년 전 조회 1,509
14년 전 조회 1,535
14년 전 조회 2,778
14년 전 조회 1,836
14년 전 조회 2,280
14년 전 조회 1,574
14년 전 조회 2,141
14년 전 조회 2,643
14년 전 조회 1,721
14년 전 조회 2,199
14년 전 조회 1,721
14년 전 조회 2,081
14년 전 조회 3,535
14년 전 조회 1,572
14년 전 조회 5,720
14년 전 조회 1,581
14년 전 조회 1,744
14년 전 조회 1,602
14년 전 조회 4,297
14년 전 조회 1,397
14년 전 조회 1,726
14년 전 조회 2,032
14년 전 조회 2,041
14년 전 조회 1,531
14년 전 조회 2,143
14년 전 조회 1,608
14년 전 조회 1,488
14년 전 조회 3,144
14년 전 조회 1,890
14년 전 조회 1,471
14년 전 조회 1,452
14년 전 조회 2,496
14년 전 조회 1,666
14년 전 조회 2,071
14년 전 조회 2,049
14년 전 조회 2,664
14년 전 조회 2,729
14년 전 조회 2,003
14년 전 조회 1,643
14년 전 조회 1,562
14년 전 조회 1,778
14년 전 조회 1,976
14년 전 조회 3,431
14년 전 조회 1,449