천

PHP ANOTATION , Reflection 입니다.

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

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,187건
+
제목 글쓴이 날짜 조회
16-02-06 조회 3,643
16-02-04 조회 3,201
16-02-04 조회 3,492
16-02-04 조회 3,169
16-02-03 조회 3,259
16-02-03 조회 3,006
16-02-03 조회 3,052
16-02-03 조회 2,968
16-02-03 조회 3,081
16-02-02 조회 3,118
16-02-02 조회 3,018
16-02-02 조회 3,041
16-02-02 조회 2,926
16-02-02 조회 3,338
16-02-01 조회 2,925
16-02-01 조회 2,733
16-02-01 조회 2,712
16-01-31 조회 2,738
16-01-31 조회 2,752
16-01-31 조회 2,753
16-01-30 조회 3,154
16-01-30 조회 2,753
16-01-30 조회 2,734
16-01-30 조회 2,931
16-01-30 조회 3,073
16-01-30 조회 2,871
16-01-29 조회 2,736
16-01-29 조회 2,739
16-01-29 조회 2,627
16-01-29 조회 2,612
16-01-28 조회 3,099
16-01-28 조회 2,947
16-01-28 조회 2,561
16-01-28 조회 2,467
16-01-28 조회 2,717
16-01-27 조회 2,652
16-01-27 조회 2,638
16-01-27 조회 2,636
16-01-26 조회 2,632
16-01-26 조회 2,610
16-01-26 조회 2,624
16-01-26 조회 2,927
16-01-25 조회 2,632
16-01-25 조회 2,679
16-01-25 조회 2,689
16-01-25 조회 2,560
16-01-24 조회 2,553
16-01-24 조회 2,553
16-01-24 조회 2,472
16-01-23 조회 2,520
16-01-23 조회 2,531
16-01-23 조회 2,507
16-01-22 조회 2,648
16-01-22 조회 2,763
16-01-22 조회 2,667
16-01-22 조회 2,750
16-01-21 조회 2,780
16-01-21 조회 2,655
16-01-21 조회 2,637
16-01-21 조회 2,642
16-01-21 조회 2,599
16-01-20 조회 2,642
16-01-20 조회 2,564
16-01-20 조회 2,515
16-01-20 조회 2,717
16-01-19 조회 2,541
16-01-19 조회 2,579
16-01-19 조회 2,566
16-01-19 조회 2,599
16-01-19 조회 2,792
16-01-18 조회 2,579
16-01-18 조회 2,568
16-01-18 조회 2,583
16-01-18 조회 2,732
16-01-17 조회 2,759
16-01-17 조회 2,612
16-01-17 조회 2,678
16-01-16 조회 2,517
16-01-16 조회 2,451
16-01-16 조회 2,513
16-01-15 조회 2,668
16-01-15 조회 2,664
16-01-15 조회 2,586
16-01-15 조회 2,518
16-01-14 조회 2,680
16-01-14 조회 2,820
16-01-14 조회 3,275
16-01-14 조회 2,570
16-01-14 조회 2,799
16-01-14 조회 2,603
16-01-13 조회 3,045
16-01-13 조회 2,661
16-01-13 조회 2,629
16-01-13 조회 2,656
16-01-13 조회 2,540
16-01-12 조회 2,963
16-01-12 조회 2,722
16-01-12 조회 2,728
16-01-12 조회 2,653
16-01-11 조회 2,776