PHP ANOTATION , Reflection 입니다.

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

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,676
16-05-11 조회 2,883
16-03-21 조회 3,025
16-03-19 조회 2,961
16-03-17 조회 2,796
16-03-17 조회 2,858
16-03-14 조회 2,885
16-03-13 조회 2,784
16-03-09 조회 2,890
16-03-08 조회 2,831
16-03-08 조회 2,633
16-03-08 조회 2,677
16-03-08 조회 2,842
16-03-07 조회 2,642
16-03-07 조회 2,682
16-02-29 조회 3,015
16-02-25 조회 3,048
16-02-22 조회 2,870
16-02-12 조회 3,088
16-02-04 조회 3,021
16-02-04 조회 3,255
16-02-04 조회 2,834
16-02-03 조회 3,101
16-02-03 조회 2,862
16-02-02 조회 2,788
16-02-02 조회 2,744
16-02-01 조회 2,713
16-01-30 조회 2,571
16-01-30 조회 2,747
16-01-30 조회 2,635
16-01-30 조회 2,612
16-01-29 조회 2,547
16-01-28 조회 2,593
16-01-28 조회 2,435
16-01-27 조회 2,469
16-01-26 조회 2,417
16-01-26 조회 2,489
16-01-25 조회 2,473
16-01-22 조회 2,401
16-01-22 조회 2,514
16-01-21 조회 2,464
16-01-19 조회 2,324
16-01-19 조회 2,422
16-01-18 조회 2,392
16-01-17 조회 2,523
16-01-14 조회 2,509
16-01-13 조회 2,676
16-01-12 조회 2,628
16-01-12 조회 2,565
16-01-11 조회 2,258
15-12-30 조회 3,045
15-12-29 조회 2,484
15-12-28 조회 2,535
15-12-09 조회 2,614
15-12-08 조회 2,817
15-12-08 조회 2,579
15-12-08 조회 2,857
15-12-07 조회 2,647
15-12-07 조회 3,019
15-12-07 조회 2,683
15-12-06 조회 2,814
15-12-06 조회 2,523
15-12-06 조회 2,729
15-12-05 조회 2,650
15-12-05 조회 2,905
15-12-05 조회 2,718
15-12-04 조회 2,588
15-12-04 조회 2,675
15-12-04 조회 2,737
15-12-03 조회 2,699
15-12-03 조회 2,740
15-12-03 조회 2,731
15-12-02 조회 2,835
15-12-02 조회 2,770
15-12-02 조회 2,893
15-12-02 조회 2,913
15-12-01 조회 2,674
15-12-01 조회 2,465
15-12-01 조회 2,539
15-11-30 조회 2,734
15-11-30 조회 2,854
15-11-30 조회 2,718
15-11-29 조회 2,554
15-11-29 조회 2,771
15-11-29 조회 2,623
15-11-28 조회 2,558
15-11-28 조회 2,578
15-11-28 조회 2,618
15-11-27 조회 2,718
15-11-27 조회 2,560
15-11-27 조회 2,574
15-11-25 조회 2,609
15-11-25 조회 2,639
15-11-25 조회 2,476
15-11-23 조회 2,723
15-11-23 조회 2,856
15-11-23 조회 2,713
15-11-21 조회 2,644
15-11-21 조회 2,544
15-11-21 조회 2,485