v

PHP ANOTATION , Reflection

· 14년 전 · 1358
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,052
14년 전 조회 2,311
14년 전 조회 1,838
14년 전 조회 2,857
14년 전 조회 1,511
14년 전 조회 1,518
14년 전 조회 1,362
14년 전 조회 2,179
14년 전 조회 1,784
14년 전 조회 1,495
14년 전 조회 6,068
14년 전 조회 2,633
14년 전 조회 1,900
14년 전 조회 1,380
14년 전 조회 1만
14년 전 조회 2,299
14년 전 조회 1,312
14년 전 조회 1,317
14년 전 조회 2,203
14년 전 조회 2,743
14년 전 조회 2,255
14년 전 조회 1,499
14년 전 조회 2,805
14년 전 조회 2,780
14년 전 조회 3,756
14년 전 조회 1,894
14년 전 조회 1,999
14년 전 조회 1,541
14년 전 조회 1,638
14년 전 조회 2,881
14년 전 조회 1,641
14년 전 조회 3,163
14년 전 조회 1,351
14년 전 조회 4,239
14년 전 조회 1,438
14년 전 조회 2,804
14년 전 조회 4,201
14년 전 조회 1,478
14년 전 조회 1,664
14년 전 조회 2,036
14년 전 조회 1,527
14년 전 조회 2,061
14년 전 조회 1,962
14년 전 조회 2,067
14년 전 조회 1,839
14년 전 조회 1,429
14년 전 조회 1,916
14년 전 조회 1,911
14년 전 조회 1,776
14년 전 조회 1,359
14년 전 조회 1,281
14년 전 조회 1,694
14년 전 조회 1,188
14년 전 조회 3,776
14년 전 조회 1,224
14년 전 조회 1,616
14년 전 조회 1,255
14년 전 조회 1,308
14년 전 조회 2,549
14년 전 조회 1,584
14년 전 조회 2,057
14년 전 조회 1,333
14년 전 조회 1,894
14년 전 조회 2,421
14년 전 조회 1,483
14년 전 조회 1,940
14년 전 조회 1,468
14년 전 조회 1,841
14년 전 조회 3,282
14년 전 조회 1,339
14년 전 조회 5,486
14년 전 조회 1,324
14년 전 조회 1,515
14년 전 조회 1,338
14년 전 조회 4,090
14년 전 조회 1,148
14년 전 조회 1,487
14년 전 조회 1,788
14년 전 조회 1,797
14년 전 조회 1,263
14년 전 조회 1,888
14년 전 조회 1,368
14년 전 조회 1,247
14년 전 조회 2,901
14년 전 조회 1,642
14년 전 조회 1,243
14년 전 조회 1,220
14년 전 조회 2,267
14년 전 조회 1,420
14년 전 조회 1,834
14년 전 조회 1,826
14년 전 조회 2,427
14년 전 조회 2,491
14년 전 조회 1,761
14년 전 조회 1,385
14년 전 조회 1,332
14년 전 조회 1,562
14년 전 조회 1,747
14년 전 조회 3,210
14년 전 조회 1,206