천

PHP ANOTATION , Reflection 입니다.

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

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-07-13 조회 2,170
16-07-12 조회 2,349
16-07-12 조회 2,378
16-07-11 조회 2,193
16-06-05 조회 2,916
16-06-03 조회 3,033
16-05-26 조회 2,957
15-09-22 조회 4,988
15-06-10 조회 4,831
14-10-25 조회 6,359
14-10-22 조회 8,984
14-09-21 조회 5,791
14-09-16 조회 5,072
14-08-22 조회 1.1만
14-08-13 조회 5,903
14-08-12 조회 5,440
14-08-12 조회 6,299
14-08-11 조회 6,926
14-06-12 조회 6,201
14-06-11 조회 5,109
14-05-09 조회 5,420
14-05-09 조회 6,383
14-05-09 조회 6,413
14-05-08 조회 5,749
14-04-17 조회 4,747
14-04-16 조회 4,580
14-04-15 조회 4,585
14-04-15 조회 4,534
14-04-15 조회 4,306
14-04-14 조회 4,288
14-04-14 조회 4,258
14-04-14 조회 4,633
14-04-14 조회 4,779
14-04-14 조회 4,760
14-04-13 조회 4,665
14-04-12 조회 4,234
14-04-12 조회 4,376
14-04-12 조회 4,483
14-04-11 조회 5,007
14-04-10 조회 4,744
14-04-10 조회 4,778
14-04-09 조회 4,936
14-04-09 조회 5,305
14-04-08 조회 6,971
13-10-30 조회 7,652
13-07-11 조회 5,135
13-03-28 조회 1.1만
13-02-27 조회 6,787
13-02-14 조회 5,606
13-01-10 조회 4,522
12-12-31 조회 5,102
12-12-20 조회 6,120
12-12-12 조회 5,279
12-12-07 조회 4,501
12-11-28 조회 4,853
12-11-22 조회 5,290
12-11-12 조회 5,655
12-09-22 조회 4,512
12-09-18 조회 4,701