천

PHP ANOTATION , Reflection 입니다.

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

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,780
16-05-11 조회 3,345
16-03-21 조회 3,125
16-03-19 조회 3,070
16-03-17 조회 2,894
16-03-17 조회 2,980
16-03-14 조회 2,992
16-03-13 조회 2,927
16-03-09 조회 3,358
16-03-08 조회 3,006
16-03-08 조회 2,814
16-03-08 조회 2,832
16-03-08 조회 2,983
16-03-07 조회 2,781
16-03-07 조회 2,775
16-02-29 조회 3,178
16-02-25 조회 3,163
16-02-22 조회 2,975
16-02-12 조회 3,265
16-02-04 조회 3,093
16-02-04 조회 3,361
16-02-04 조회 2,999
16-02-03 조회 3,160
16-02-03 조회 2,978
16-02-02 조회 2,929
16-02-02 조회 2,811
16-02-01 조회 2,825
16-01-30 조회 2,654
16-01-30 조회 2,833
16-01-30 조회 2,934
16-01-30 조회 2,755
16-01-29 조회 2,639
16-01-28 조회 2,937
16-01-28 조회 2,581
16-01-27 조회 2,542
16-01-26 조회 2,505
16-01-26 조회 2,598
16-01-25 조회 2,572
16-01-22 조회 2,551
16-01-22 조회 2,628
16-01-21 조회 2,528
16-01-19 조회 2,440
16-01-19 조회 2,492
16-01-18 조회 2,460
16-01-17 조회 2,635
16-01-14 조회 2,573
16-01-13 조회 2,750
16-01-12 조회 2,863
16-01-12 조회 2,616
16-01-11 조회 2,567
15-12-30 조회 3,187
15-12-29 조회 2,569
15-12-28 조회 2,599
15-12-09 조회 2,670
15-12-08 조회 2,875
15-12-08 조회 2,624
15-12-08 조회 2,901
15-12-07 조회 2,705
15-12-07 조회 3,076
15-12-07 조회 2,732
15-12-06 조회 2,862
15-12-06 조회 2,567
15-12-06 조회 2,793
15-12-05 조회 2,722
15-12-05 조회 2,980
15-12-05 조회 2,766
15-12-04 조회 2,626
15-12-04 조회 2,741
15-12-04 조회 2,789
15-12-03 조회 2,746
15-12-03 조회 2,779
15-12-03 조회 2,795
15-12-02 조회 2,886
15-12-02 조회 2,824
15-12-02 조회 2,956
15-12-02 조회 3,002
15-12-01 조회 2,716
15-12-01 조회 2,511
15-12-01 조회 2,587
15-11-30 조회 2,780
15-11-30 조회 2,922
15-11-30 조회 2,835
15-11-29 조회 2,605
15-11-29 조회 2,846
15-11-29 조회 2,667
15-11-28 조회 2,605
15-11-28 조회 2,622
15-11-28 조회 2,666
15-11-27 조회 2,760
15-11-27 조회 2,607
15-11-27 조회 2,618
15-11-25 조회 2,687
15-11-25 조회 2,751
15-11-25 조회 2,547
15-11-23 조회 2,824
15-11-23 조회 2,956
15-11-23 조회 2,796
15-11-21 조회 2,691
15-11-21 조회 2,590
15-11-21 조회 2,535