천

PHP ANOTATION , Reflection 입니다.

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

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-11 조회 3,037
16-02-15 조회 3,284
16-02-02 조회 2,947
16-01-25 조회 2,571
16-01-18 조회 2,655
16-01-08 조회 2,593
16-01-07 조회 2,604
16-01-05 조회 2,642
16-01-05 조회 2,936
16-01-05 조회 2,762
16-01-05 조회 2,792
16-01-04 조회 2,646
16-01-04 조회 2,656
16-01-04 조회 2,607
16-01-04 조회 2,518
15-12-30 조회 2,875
15-12-24 조회 2,689
15-12-24 조회 2,684
15-12-24 조회 2,707
15-12-24 조회 2,665
15-12-23 조회 2,655
15-12-16 조회 2,739
15-12-15 조회 2,808
15-12-11 조회 2,935
15-12-10 조회 2,789
15-11-09 조회 2,778
15-11-09 조회 3,004
15-10-06 조회 3,333
15-10-02 조회 3,109
15-05-29 조회 4,444
15-02-02 조회 4,424
15-01-18 조회 4,398
14-10-25 조회 8,370
14-10-25 조회 5,141
14-10-22 조회 7,145
14-10-22 조회 4,851
14-10-22 조회 4,803
14-10-18 조회 5,674
14-10-17 조회 6,051
14-10-17 조회 5,426
14-10-17 조회 8,905
14-10-17 조회 6,434
14-10-13 조회 4,355
14-10-13 조회 4,460
14-10-07 조회 6,143
14-09-24 조회 3,906
14-09-23 조회 3,977
14-09-22 조회 4,875
14-09-22 조회 6,106
14-09-22 조회 4,075
14-09-22 조회 3,752
14-09-21 조회 4,359
14-09-21 조회 3,832
14-09-20 조회 3,838
14-09-20 조회 3,747
14-09-20 조회 3,921
14-09-19 조회 3,858
14-09-19 조회 4,013
14-09-19 조회 3,903
14-09-19 조회 4,292
14-09-19 조회 3,917
14-09-19 조회 3,849
14-09-19 조회 4,134
14-09-19 조회 3,877
14-09-19 조회 3,926
14-09-19 조회 3,911
14-09-18 조회 3,983
14-09-18 조회 3,946
14-09-18 조회 4,213
14-09-18 조회 4,179
14-09-18 조회 4,188
14-09-18 조회 4,891
14-09-18 조회 5,446
14-09-18 조회 5,328
14-09-18 조회 4,124
14-09-18 조회 4,621
14-09-18 조회 4,247
14-08-30 조회 5,457
14-08-06 조회 6,001
14-08-06 조회 5,613
14-08-03 조회 5,260
14-06-12 조회 5,534
14-05-11 조회 3,713
14-05-11 조회 4,476
14-05-11 조회 4,581
14-05-09 조회 1.3만
14-05-01 조회 5,117
14-03-30 조회 4,384
14-03-23 조회 8,005
14-02-12 조회 3,881
13-10-29 조회 7,848
13-10-28 조회 8,674
13-09-29 조회 6,638
13-09-29 조회 4,265
13-07-23 조회 5,131
13-07-23 조회 1.2만
13-07-14 조회 4,679
13-07-14 조회 5,059
13-07-14 조회 6,006
13-07-14 조회 5,302