v

PHP ANOTATION , Reflection

· 14년 전 · 1412
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,127
14년 전 조회 2,378
14년 전 조회 1,902
14년 전 조회 2,929
14년 전 조회 1,576
14년 전 조회 1,591
14년 전 조회 1,427
14년 전 조회 2,249
14년 전 조회 1,846
14년 전 조회 1,573
14년 전 조회 6,132
14년 전 조회 2,707
14년 전 조회 1,960
14년 전 조회 1,464
14년 전 조회 1만
14년 전 조회 2,379
14년 전 조회 1,381
14년 전 조회 1,390
14년 전 조회 2,260
14년 전 조회 2,815
14년 전 조회 2,335
14년 전 조회 1,565
14년 전 조회 2,870
14년 전 조회 2,827
14년 전 조회 3,819
14년 전 조회 1,952
14년 전 조회 2,064
14년 전 조회 1,611
14년 전 조회 1,697
14년 전 조회 2,927
14년 전 조회 1,712
14년 전 조회 3,213
14년 전 조회 1,422
14년 전 조회 4,317
14년 전 조회 1,499
14년 전 조회 2,866
14년 전 조회 4,286
14년 전 조회 1,544
14년 전 조회 1,730
14년 전 조회 2,095
14년 전 조회 1,601
14년 전 조회 2,150
14년 전 조회 2,020
14년 전 조회 2,140
14년 전 조회 1,894
14년 전 조회 1,505
14년 전 조회 1,969
14년 전 조회 1,980
14년 전 조회 1,835
14년 전 조회 1,413
14년 전 조회 1,350
14년 전 조회 1,762
14년 전 조회 1,261
14년 전 조회 3,855
14년 전 조회 1,295
14년 전 조회 1,693
14년 전 조회 1,314
14년 전 조회 1,364
14년 전 조회 2,605
14년 전 조회 1,653
14년 전 조회 2,106
14년 전 조회 1,397
14년 전 조회 1,963
14년 전 조회 2,485
14년 전 조회 1,562
14년 전 조회 2,010
14년 전 조회 1,537
14년 전 조회 1,923
14년 전 조회 3,360
14년 전 조회 1,403
14년 전 조회 5,558
14년 전 조회 1,386
14년 전 조회 1,571
14년 전 조회 1,409
14년 전 조회 4,137
14년 전 조회 1,214
14년 전 조회 1,553
14년 전 조회 1,857
14년 전 조회 1,867
14년 전 조회 1,337
14년 전 조회 1,972
14년 전 조회 1,434
14년 전 조회 1,314
14년 전 조회 2,965
14년 전 조회 1,735
14년 전 조회 1,302
14년 전 조회 1,282
14년 전 조회 2,328
14년 전 조회 1,511
14년 전 조회 1,906
14년 전 조회 1,884
14년 전 조회 2,485
14년 전 조회 2,557
14년 전 조회 1,838
14년 전 조회 1,451
14년 전 조회 1,395
14년 전 조회 1,626
14년 전 조회 1,822
14년 전 조회 3,271
14년 전 조회 1,289