천

PHP ANOTATION , Reflection 입니다.

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

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-01-11 조회 2,681
16-01-11 조회 2,618
16-01-11 조회 2,804
16-01-08 조회 2,860
16-01-08 조회 2,614
16-01-07 조회 2,620
16-01-05 조회 2,691
16-01-05 조회 2,656
16-01-05 조회 2,956
16-01-05 조회 2,933
16-01-05 조회 2,810
16-01-04 조회 2,669
16-01-04 조회 2,678
16-01-04 조회 2,623
16-01-04 조회 2,539
16-01-03 조회 3,413
16-01-03 조회 2,683
16-01-03 조회 3,131
16-01-02 조회 2,902
16-01-02 조회 2,635
16-01-02 조회 2,749
16-01-02 조회 2,525
16-01-01 조회 2,821
16-01-01 조회 2,754
16-01-01 조회 2,853
15-12-31 조회 2,597
15-12-31 조회 3,322
15-12-31 조회 2,968
15-12-31 조회 2,992
15-12-31 조회 2,751
15-12-30 조회 2,689
15-12-30 조회 3,260
15-12-30 조회 2,893
15-12-30 조회 2,790
15-12-30 조회 2,692
15-12-30 조회 2,612
15-12-29 조회 2,633
15-12-29 조회 2,873
15-12-29 조회 3,108
15-12-29 조회 2,649
15-12-28 조회 2,659
15-12-28 조회 2,687
15-12-28 조회 2,783
15-12-28 조회 2,568
15-12-27 조회 3,241
15-12-27 조회 2,693
15-12-27 조회 2,592
15-12-27 조회 2,651
15-12-26 조회 2,610
15-12-26 조회 2,684
15-12-26 조회 2,710
15-12-25 조회 3,576
15-12-25 조회 2,567
15-12-25 조회 2,575
15-12-25 조회 2,525
15-12-24 조회 3,074
15-12-24 조회 2,703
15-12-24 조회 2,699
15-12-24 조회 2,725
15-12-24 조회 2,679
15-12-23 조회 2,963
15-12-23 조회 2,670
15-12-23 조회 2,538
15-12-23 조회 2,669
15-12-23 조회 2,619
15-12-22 조회 2,795
15-12-22 조회 2,665
15-12-22 조회 2,634
15-12-22 조회 2,547
15-12-21 조회 2,572
15-12-21 조회 2,599
15-12-21 조회 2,580
15-12-20 조회 2,632
15-12-20 조회 2,797
15-12-20 조회 2,564
15-12-19 조회 2,644
15-12-19 조회 2,640
15-12-19 조회 2,651
15-12-18 조회 3,066
15-12-18 조회 2,616
15-12-18 조회 2,611
15-12-18 조회 2,584
15-12-17 조회 2,658
15-12-17 조회 2,572
15-12-17 조회 2,597
15-12-17 조회 2,553
15-12-16 조회 2,568
15-12-16 조회 2,608
15-12-16 조회 2,550
15-12-16 조회 2,763
15-12-15 조회 2,889
15-12-15 조회 2,825
15-12-15 조회 2,559
15-12-15 조회 2,547
15-12-15 조회 2,545
15-12-14 조회 2,632
15-12-14 조회 2,696
15-12-14 조회 2,520
15-12-13 조회 2,484
15-12-13 조회 2,535