천

PHP ANOTATION , Reflection 입니다.

· 2015-12-05 (토) 20:43:57 · 2705

PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
http://code.google.com/p/addendum/
 
 
 
잘만 활용 하면, 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'

|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
15-12-13 조회 2,876
15-12-11 조회 3,341
15-12-11 조회 3,024
15-12-11 조회 2,844
15-12-11 조회 2,509
15-12-11 조회 2,471
15-12-11 조회 2,487
15-12-10 조회 2,439
15-12-10 조회 2,519
15-12-10 조회 2,494
15-12-10 조회 2,735
15-12-09 조회 2,651
15-12-08 조회 3,546
15-12-08 조회 2,860
15-12-08 조회 2,613
15-12-08 조회 2,888
15-12-07 조회 2,975
15-12-07 조회 2,695
15-12-07 조회 3,058
15-12-07 조회 2,715
15-12-06 조회 2,852
15-12-06 조회 2,552
15-12-06 조회 2,774
15-12-05 조회 2,706
15-12-05 조회 2,961
15-12-05 조회 2,756
15-12-04 조회 2,618
15-12-04 조회 2,728
15-12-04 조회 2,777
15-12-03 조회 2,737
15-12-03 조회 2,768
15-12-03 조회 2,783
15-12-03 조회 2,864
15-12-03 조회 3,127
15-12-03 조회 2,639
15-12-02 조회 2,867
15-12-02 조회 2,825
15-12-02 조회 2,810
15-12-02 조회 2,941
15-12-02 조회 2,991
15-12-01 조회 2,705
15-12-01 조회 2,501
15-12-01 조회 2,575
15-11-30 조회 2,770
15-11-30 조회 2,904
15-11-30 조회 2,823
15-11-29 조회 2,598
15-11-29 조회 2,830
15-11-29 조회 2,655
15-11-28 조회 2,593
15-11-28 조회 2,609
15-11-28 조회 2,652
15-11-27 조회 2,749
15-11-27 조회 2,594
15-11-27 조회 2,611
15-11-26 조회 2,760
15-11-26 조회 3,604
15-11-25 조회 2,697
15-11-25 조회 2,670
15-11-25 조회 2,723
15-11-25 조회 2,526
15-11-25 조회 2,868
15-11-23 조회 2,806
15-11-23 조회 2,941
15-11-23 조회 2,776
15-11-21 조회 2,680
15-11-21 조회 2,582
15-11-21 조회 2,522
15-11-20 조회 2,517
15-11-20 조회 2,475
15-11-20 조회 2,605
15-11-20 조회 2,862
15-11-18 조회 2,721
15-11-18 조회 2,641
15-11-18 조회 2,620
15-11-17 조회 2,818
15-11-17 조회 2,576
15-11-17 조회 2,664
15-11-16 조회 2,602
15-11-16 조회 2,570
15-11-16 조회 2,763
15-11-15 조회 2,768
15-11-15 조회 2,629
15-11-15 조회 2,702
15-11-13 조회 3,573
15-11-12 조회 3,461
15-11-12 조회 2,911
15-11-12 조회 3,584
15-11-11 조회 2,710
15-11-11 조회 2,973
15-11-11 조회 3,229
15-11-09 조회 2,726
15-11-09 조회 2,957
15-11-09 조회 2,905
15-11-09 조회 2,678
15-11-09 조회 2,733
15-11-09 조회 2,926
15-11-06 조회 3,324
15-11-05 조회 2,765
15-11-05 조회 2,660