천

PHP ANOTATION , Reflection 입니다.

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

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건
+
제목 글쓴이 날짜 조회
15-12-13 조회 2,866
15-12-11 조회 3,332
15-12-11 조회 3,000
15-12-11 조회 2,798
15-12-11 조회 2,488
15-12-11 조회 2,462
15-12-11 조회 2,471
15-12-10 조회 2,431
15-12-10 조회 2,509
15-12-10 조회 2,483
15-12-10 조회 2,722
15-12-09 조회 2,640
15-12-08 조회 3,531
15-12-08 조회 2,844
15-12-08 조회 2,605
15-12-08 조회 2,881
15-12-07 조회 2,938
15-12-07 조회 2,678
15-12-07 조회 3,042
15-12-07 조회 2,712
15-12-06 조회 2,840
15-12-06 조회 2,539
15-12-06 조회 2,760
15-12-05 조회 2,693
15-12-05 조회 2,940
15-12-05 조회 2,739
15-12-04 조회 2,610
15-12-04 조회 2,718
15-12-04 조회 2,763
15-12-03 조회 2,721
15-12-03 조회 2,757
15-12-03 조회 2,761
15-12-03 조회 2,853
15-12-03 조회 3,109
15-12-03 조회 2,617
15-12-02 조회 2,854
15-12-02 조회 2,812
15-12-02 조회 2,798
15-12-02 조회 2,919
15-12-02 조회 2,967
15-12-01 조회 2,698
15-12-01 조회 2,490
15-12-01 조회 2,565
15-11-30 조회 2,758
15-11-30 조회 2,885
15-11-30 조회 2,797
15-11-29 조회 2,583
15-11-29 조회 2,810
15-11-29 조회 2,645
15-11-28 조회 2,583
15-11-28 조회 2,601
15-11-28 조회 2,643
15-11-27 조회 2,742
15-11-27 조회 2,583
15-11-27 조회 2,598
15-11-26 조회 2,744
15-11-26 조회 3,577
15-11-25 조회 2,681
15-11-25 조회 2,643
15-11-25 조회 2,704
15-11-25 조회 2,508
15-11-25 조회 2,862
15-11-23 조회 2,787
15-11-23 조회 2,914
15-11-23 조회 2,764
15-11-21 조회 2,667
15-11-21 조회 2,574
15-11-21 조회 2,514
15-11-20 조회 2,509
15-11-20 조회 2,466
15-11-20 조회 2,590
15-11-20 조회 2,855
15-11-18 조회 2,635
15-11-18 조회 2,629
15-11-18 조회 2,602
15-11-17 조회 2,812
15-11-17 조회 2,561
15-11-17 조회 2,572
15-11-16 조회 2,588
15-11-16 조회 2,558
15-11-16 조회 2,755
15-11-15 조회 2,756
15-11-15 조회 2,613
15-11-15 조회 2,684
15-11-13 조회 3,568
15-11-12 조회 3,450
15-11-12 조회 2,908
15-11-12 조회 3,577
15-11-11 조회 2,695
15-11-11 조회 2,962
15-11-11 조회 3,218
15-11-09 조회 2,704
15-11-09 조회 2,924
15-11-09 조회 2,880
15-11-09 조회 2,666
15-11-09 조회 2,725
15-11-09 조회 2,906
15-11-06 조회 3,310
15-11-05 조회 2,751
15-11-05 조회 2,652