천

PHP ANOTATION , Reflection 입니다.

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

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-03 조회 3,035
15-07-30 조회 3,420
15-06-08 조회 5,563
15-05-27 조회 4,420
15-01-08 조회 6,722
14-12-30 조회 5,451
14-10-10 조회 5,444
14-08-13 조회 6,358
14-08-11 조회 5,215
14-08-06 조회 6,549
14-03-19 조회 7,443
13-04-26 조회 9,598
12-12-15 조회 5,122
12-12-15 조회 7,358
12-12-11 조회 5,503
12-11-21 조회 6,030
12-10-11 조회 5,107
12-10-03 조회 4,801
12-09-20 조회 6,099
12-09-02 조회 4,275
12-08-29 조회 5,288
12-08-29 조회 4,166
12-08-24 조회 4,270
12-08-18 조회 4,487
12-08-17 조회 4,529
12-08-16 조회 3,787
12-08-06 조회 5,563
12-08-05 조회 4,849
12-08-03 조회 4,565
12-08-03 조회 4,717
12-07-29 조회 3,564
12-07-24 조회 4,155
12-07-22 조회 3,621
12-07-20 조회 4,383
12-07-19 조회 4,724
12-07-19 조회 3,953
12-07-19 조회 3,899
12-07-19 조회 5,564
12-07-19 조회 3,508
12-07-18 조회 5,201
12-07-15 조회 4,178
12-07-14 조회 3,847
12-07-12 조회 4,518
12-07-11 조회 3,792
12-07-11 조회 3,512
12-07-11 조회 3,489
12-07-10 조회 4,678
12-07-09 조회 3,425
12-07-09 조회 4,242
12-07-09 조회 4,662
12-07-08 조회 4,577
12-07-07 조회 5,500
12-07-06 조회 4,754
12-07-06 조회 4,023
12-07-06 조회 3,907
12-07-06 조회 3,848
12-07-02 조회 5,523
12-07-02 조회 4,220
12-06-29 조회 3,749
12-06-28 조회 4,366
12-06-26 조회 3,863
12-06-26 조회 4,983
12-06-21 조회 3,960
12-06-20 조회 4,660
12-06-20 조회 4,297
12-06-15 조회 4,651
12-06-15 조회 4,388
12-06-13 조회 7,404
12-06-05 조회 7,378
12-06-04 조회 3,954
12-06-03 조회 3,803
12-05-31 조회 3,798
12-05-28 조회 6,646
12-05-27 조회 3,878
12-05-25 조회 4,015
12-05-23 조회 4,423
12-05-21 조회 5,134
12-05-17 조회 4,066
12-05-17 조회 3,984
12-05-09 조회 4,061
12-05-07 조회 4,319
12-05-02 조회 4,503
12-05-01 조회 4,680
12-04-30 조회 3,430
12-04-30 조회 4,373
12-04-25 조회 4,463
12-04-25 조회 4,885
12-04-24 조회 3,849
12-04-24 조회 4,624
12-04-23 조회 3,612
12-04-20 조회 3,273
12-04-17 조회 5,457
12-04-16 조회 4,394
12-04-14 조회 3,673
12-04-14 조회 3,709
12-04-14 조회 3,756
12-04-13 조회 3,377
12-04-13 조회 4,564
12-04-13 조회 6,204
12-04-12 조회 3,369