천

PHP ANOTATION , Reflection 입니다.

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

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,910
15-12-11 조회 3,373
15-12-11 조회 3,070
15-12-11 조회 2,907
15-12-11 조회 2,559
15-12-11 조회 2,520
15-12-11 조회 2,525
15-12-10 조회 2,480
15-12-10 조회 2,548
15-12-10 조회 2,520
15-12-10 조회 2,766
15-12-09 조회 2,687
15-12-08 조회 3,610
15-12-08 조회 2,892
15-12-08 조회 2,640
15-12-08 조회 2,922
15-12-07 조회 3,004
15-12-07 조회 2,721
15-12-07 조회 3,102
15-12-07 조회 2,753
15-12-06 조회 2,876
15-12-06 조회 2,585
15-12-06 조회 2,827
15-12-05 조회 2,752
15-12-05 조회 3,005
15-12-05 조회 2,778
15-12-04 조회 2,644
15-12-04 조회 2,754
15-12-04 조회 2,804
15-12-03 조회 2,760
15-12-03 조회 2,792
15-12-03 조회 2,823
15-12-03 조회 2,903
15-12-03 조회 3,162
15-12-03 조회 2,682
15-12-02 조회 2,902
15-12-02 조회 2,855
15-12-02 조회 2,842
15-12-02 조회 2,993
15-12-02 조회 3,040
15-12-01 조회 2,731
15-12-01 조회 2,524
15-12-01 조회 2,602
15-11-30 조회 2,795
15-11-30 조회 2,951
15-11-30 조회 2,852
15-11-29 조회 2,618
15-11-29 조회 2,870
15-11-29 조회 2,685
15-11-28 조회 2,617
15-11-28 조회 2,646
15-11-28 조회 2,676
15-11-27 조회 2,769
15-11-27 조회 2,623
15-11-27 조회 2,638
15-11-26 조회 2,800
15-11-26 조회 3,657
15-11-25 조회 2,758
15-11-25 조회 2,713
15-11-25 조회 2,772
15-11-25 조회 2,568
15-11-25 조회 2,918
15-11-23 조회 2,834
15-11-23 조회 2,981
15-11-23 조회 2,814
15-11-21 조회 2,708
15-11-21 조회 2,607
15-11-21 조회 2,550
15-11-20 조회 2,544
15-11-20 조회 2,497
15-11-20 조회 2,627
15-11-20 조회 2,882
15-11-18 조회 2,782
15-11-18 조회 2,658
15-11-18 조회 2,642
15-11-17 조회 2,845
15-11-17 조회 2,603
15-11-17 조회 2,746
15-11-16 조회 2,630
15-11-16 조회 2,596
15-11-16 조회 2,780
15-11-15 조회 2,795
15-11-15 조회 2,652
15-11-15 조회 2,742
15-11-13 조회 3,597
15-11-12 조회 3,484
15-11-12 조회 2,938
15-11-12 조회 3,605
15-11-11 조회 2,742
15-11-11 조회 3,004
15-11-11 조회 3,254
15-11-09 조회 2,758
15-11-09 조회 2,987
15-11-09 조회 2,953
15-11-09 조회 2,711
15-11-09 조회 2,761
15-11-09 조회 3,006
15-11-06 조회 3,349
15-11-05 조회 2,810
15-11-05 조회 2,692