v

PHP ANOTATION , Reflection

· 14년 전 · 1527
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,285
14년 전 조회 2,526
14년 전 조회 2,055
14년 전 조회 3,071
14년 전 조회 1,727
14년 전 조회 1,754
14년 전 조회 1,583
14년 전 조회 2,390
14년 전 조회 2,001
14년 전 조회 1,711
14년 전 조회 6,263
14년 전 조회 2,850
14년 전 조회 2,109
14년 전 조회 1,608
14년 전 조회 1만
14년 전 조회 2,501
14년 전 조회 1,538
14년 전 조회 1,540
14년 전 조회 2,408
14년 전 조회 2,945
14년 전 조회 2,467
14년 전 조회 1,708
14년 전 조회 2,996
14년 전 조회 2,939
14년 전 조회 3,965
14년 전 조회 2,063
14년 전 조회 2,224
14년 전 조회 1,758
14년 전 조회 1,799
14년 전 조회 3,046
14년 전 조회 1,838
14년 전 조회 3,330
14년 전 조회 1,569
14년 전 조회 4,446
14년 전 조회 1,632
14년 전 조회 3,012
14년 전 조회 4,409
14년 전 조회 1,677
14년 전 조회 1,851
14년 전 조회 2,211
14년 전 조회 1,747
14년 전 조회 2,297
14년 전 조회 2,166
14년 전 조회 2,283
14년 전 조회 2,049
14년 전 조회 1,649
14년 전 조회 2,105
14년 전 조회 2,088
14년 전 조회 1,966
14년 전 조회 1,528
14년 전 조회 1,491
14년 전 조회 1,911
14년 전 조회 1,412
14년 전 조회 3,985
14년 전 조회 1,424
14년 전 조회 1,834
14년 전 조회 1,473
14년 전 조회 1,501
14년 전 조회 2,748
14년 전 조회 1,811
14년 전 조회 2,249
14년 전 조회 1,533
14년 전 조회 2,110
14년 전 조회 2,611
14년 전 조회 1,685
14년 전 조회 2,156
14년 전 조회 1,696
14년 전 조회 2,052
14년 전 조회 3,498
14년 전 조회 1,529
14년 전 조회 5,689
14년 전 조회 1,546
14년 전 조회 1,716
14년 전 조회 1,566
14년 전 조회 4,254
14년 전 조회 1,356
14년 전 조회 1,696
14년 전 조회 1,988
14년 전 조회 2,002
14년 전 조회 1,487
14년 전 조회 2,109
14년 전 조회 1,576
14년 전 조회 1,450
14년 전 조회 3,097
14년 전 조회 1,849
14년 전 조회 1,437
14년 전 조회 1,421
14년 전 조회 2,459
14년 전 조회 1,624
14년 전 조회 2,024
14년 전 조회 2,012
14년 전 조회 2,629
14년 전 조회 2,689
14년 전 조회 1,962
14년 전 조회 1,602
14년 전 조회 1,528
14년 전 조회 1,747
14년 전 조회 1,950
14년 전 조회 3,401
14년 전 조회 1,420