천

PHP ANOTATION , Reflection 입니다.

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

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건
+
제목 글쓴이 날짜 조회
16-06-30 조회 2,774
16-05-11 조회 3,015
16-03-21 조회 3,109
16-03-19 조회 3,064
16-03-17 조회 2,884
16-03-17 조회 2,970
16-03-14 조회 2,987
16-03-13 조회 2,912
16-03-09 조회 3,342
16-03-08 조회 2,993
16-03-08 조회 2,800
16-03-08 조회 2,821
16-03-08 조회 2,972
16-03-07 조회 2,771
16-03-07 조회 2,770
16-02-29 조회 3,162
16-02-25 조회 3,152
16-02-22 조회 2,963
16-02-12 조회 3,248
16-02-04 조회 3,086
16-02-04 조회 3,351
16-02-04 조회 2,967
16-02-03 조회 3,156
16-02-03 조회 2,971
16-02-02 조회 2,922
16-02-02 조회 2,803
16-02-01 조회 2,815
16-01-30 조회 2,646
16-01-30 조회 2,830
16-01-30 조회 2,928
16-01-30 조회 2,751
16-01-29 조회 2,634
16-01-28 조회 2,929
16-01-28 조회 2,573
16-01-27 조회 2,536
16-01-26 조회 2,496
16-01-26 조회 2,588
16-01-25 조회 2,565
16-01-22 조회 2,542
16-01-22 조회 2,617
16-01-21 조회 2,524
16-01-19 조회 2,432
16-01-19 조회 2,486
16-01-18 조회 2,456
16-01-17 조회 2,628
16-01-14 조회 2,565
16-01-13 조회 2,745
16-01-12 조회 2,686
16-01-12 조회 2,605
16-01-11 조회 2,560
15-12-30 조회 3,178
15-12-29 조회 2,560
15-12-28 조회 2,586
15-12-09 조회 2,660
15-12-08 조회 2,869
15-12-08 조회 2,618
15-12-08 조회 2,895
15-12-07 조회 2,699
15-12-07 조회 3,066
15-12-07 조회 2,726
15-12-06 조회 2,858
15-12-06 조회 2,561
15-12-06 조회 2,782
15-12-05 조회 2,714
15-12-05 조회 2,970
15-12-05 조회 2,763
15-12-04 조회 2,622
15-12-04 조회 2,735
15-12-04 조회 2,781
15-12-03 조회 2,742
15-12-03 조회 2,774
15-12-03 조회 2,787
15-12-02 조회 2,880
15-12-02 조회 2,816
15-12-02 조회 2,945
15-12-02 조회 2,996
15-12-01 조회 2,710
15-12-01 조회 2,506
15-12-01 조회 2,580
15-11-30 조회 2,777
15-11-30 조회 2,914
15-11-30 조회 2,830
15-11-29 조회 2,600
15-11-29 조회 2,839
15-11-29 조회 2,662
15-11-28 조회 2,601
15-11-28 조회 2,616
15-11-28 조회 2,660
15-11-27 조회 2,755
15-11-27 조회 2,603
15-11-27 조회 2,614
15-11-25 조회 2,681
15-11-25 조회 2,744
15-11-25 조회 2,540
15-11-23 조회 2,817
15-11-23 조회 2,950
15-11-23 조회 2,788
15-11-21 조회 2,686
15-11-21 조회 2,585
15-11-21 조회 2,529