v

PHP ANOTATION , Reflection

· 14년 전 · 1543
PHP 에서도 anotation 드리븐을 구현 할 수 있을거 같내요 ㅎ;
 
잘만 활용 하면, 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'
 
 
 
 
 
 
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 2,307
14년 전 조회 2,543
14년 전 조회 2,074
14년 전 조회 3,092
14년 전 조회 1,742
14년 전 조회 1,762
14년 전 조회 1,597
14년 전 조회 2,399
14년 전 조회 2,016
14년 전 조회 1,720
14년 전 조회 6,276
14년 전 조회 2,863
14년 전 조회 2,122
14년 전 조회 1,620
14년 전 조회 1만
14년 전 조회 2,515
14년 전 조회 1,555
14년 전 조회 1,556
14년 전 조회 2,416
14년 전 조회 2,958
14년 전 조회 2,479
14년 전 조회 1,722
14년 전 조회 3,010
14년 전 조회 2,955
14년 전 조회 3,976
14년 전 조회 2,073
14년 전 조회 2,242
14년 전 조회 1,778
14년 전 조회 1,821
14년 전 조회 3,059
14년 전 조회 1,856
14년 전 조회 3,348
14년 전 조회 1,584
14년 전 조회 4,468
14년 전 조회 1,644
14년 전 조회 3,033
14년 전 조회 4,427
14년 전 조회 1,693
14년 전 조회 1,869
14년 전 조회 2,225
14년 전 조회 1,765
14년 전 조회 2,312
14년 전 조회 2,184
14년 전 조회 2,301
14년 전 조회 2,067
14년 전 조회 1,661
14년 전 조회 2,118
14년 전 조회 2,108
14년 전 조회 1,980
14년 전 조회 1,544
14년 전 조회 1,509
14년 전 조회 1,933
14년 전 조회 1,433
14년 전 조회 4,000
14년 전 조회 1,445
14년 전 조회 1,848
14년 전 조회 1,496
14년 전 조회 1,515
14년 전 조회 2,764
14년 전 조회 1,824
14년 전 조회 2,260
14년 전 조회 1,549
14년 전 조회 2,127
14년 전 조회 2,635
14년 전 조회 1,706
14년 전 조회 2,185
14년 전 조회 1,710
14년 전 조회 2,066
14년 전 조회 3,520
14년 전 조회 1,552
14년 전 조회 5,706
14년 전 조회 1,567
14년 전 조회 1,734
14년 전 조회 1,582
14년 전 조회 4,276
14년 전 조회 1,381
14년 전 조회 1,716
14년 전 조회 2,012
14년 전 조회 2,027
14년 전 조회 1,514
14년 전 조회 2,123
14년 전 조회 1,591
14년 전 조회 1,469
14년 전 조회 3,126
14년 전 조회 1,869
14년 전 조회 1,458
14년 전 조회 1,439
14년 전 조회 2,477
14년 전 조회 1,649
14년 전 조회 2,048
14년 전 조회 2,036
14년 전 조회 2,648
14년 전 조회 2,714
14년 전 조회 1,985
14년 전 조회 1,624
14년 전 조회 1,553
14년 전 조회 1,768
14년 전 조회 1,965
14년 전 조회 3,422
14년 전 조회 1,437