천

PHP ANOTATION , Reflection 입니다.

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

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,947
15-12-11 조회 3,416
15-12-11 조회 3,129
15-12-11 조회 2,952
15-12-11 조회 2,609
15-12-11 조회 2,571
15-12-11 조회 2,573
15-12-10 조회 2,530
15-12-10 조회 2,592
15-12-10 조회 2,567
15-12-10 조회 2,815
15-12-09 조회 2,725
15-12-08 조회 3,683
15-12-08 조회 2,938
15-12-08 조회 2,683
15-12-08 조회 2,965
15-12-07 조회 3,040
15-12-07 조회 2,753
15-12-07 조회 3,184
15-12-07 조회 2,781
15-12-06 조회 2,909
15-12-06 조회 2,623
15-12-06 조회 2,959
15-12-05 조회 2,787
15-12-05 조회 3,087
15-12-05 조회 2,807
15-12-04 조회 2,682
15-12-04 조회 2,789
15-12-04 조회 2,843
15-12-03 조회 2,795
15-12-03 조회 2,821
15-12-03 조회 2,869
15-12-03 조회 2,932
15-12-03 조회 3,209
15-12-03 조회 2,724
15-12-02 조회 2,960
15-12-02 조회 2,902
15-12-02 조회 2,879
15-12-02 조회 3,076
15-12-02 조회 3,216
15-12-01 조회 2,762
15-12-01 조회 2,557
15-12-01 조회 2,635
15-11-30 조회 2,821
15-11-30 조회 3,027
15-11-30 조회 2,891
15-11-29 조회 2,647
15-11-29 조회 2,909
15-11-29 조회 2,707
15-11-28 조회 2,646
15-11-28 조회 2,678
15-11-28 조회 2,711
15-11-27 조회 2,798
15-11-27 조회 2,655
15-11-27 조회 2,667
15-11-26 조회 2,839
15-11-26 조회 3,706
15-11-25 조회 2,805
15-11-25 조회 2,763
15-11-25 조회 2,813
15-11-25 조회 2,605
15-11-25 조회 2,970
15-11-23 조회 2,886
15-11-23 조회 3,058
15-11-23 조회 2,852
15-11-21 조회 2,757
15-11-21 조회 2,631
15-11-21 조회 2,577
15-11-20 조회 2,573
15-11-20 조회 2,523
15-11-20 조회 2,658
15-11-20 조회 2,916
15-11-18 조회 2,816
15-11-18 조회 2,694
15-11-18 조회 2,679
15-11-17 조회 2,882
15-11-17 조회 2,641
15-11-17 조회 2,776
15-11-16 조회 2,658
15-11-16 조회 2,625
15-11-16 조회 2,817
15-11-15 조회 2,819
15-11-15 조회 2,686
15-11-15 조회 2,864
15-11-13 조회 3,628
15-11-12 조회 3,512
15-11-12 조회 2,979
15-11-12 조회 3,650
15-11-11 조회 2,777
15-11-11 조회 3,031
15-11-11 조회 3,285
15-11-09 조회 2,796
15-11-09 조회 3,017
15-11-09 조회 3,004
15-11-09 조회 2,749
15-11-09 조회 2,799
15-11-09 조회 3,243
15-11-06 조회 3,392
15-11-05 조회 2,870
15-11-05 조회 2,728