v

PHP ANOTATION , Reflection

· 14년 전 · 1432
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,155
14년 전 조회 2,402
14년 전 조회 1,932
14년 전 조회 2,956
14년 전 조회 1,611
14년 전 조회 1,624
14년 전 조회 1,445
14년 전 조회 2,278
14년 전 조회 1,869
14년 전 조회 1,600
14년 전 조회 6,154
14년 전 조회 2,731
14년 전 조회 1,983
14년 전 조회 1,496
14년 전 조회 1만
14년 전 조회 2,395
14년 전 조회 1,412
14년 전 조회 1,413
14년 전 조회 2,286
14년 전 조회 2,840
14년 전 조회 2,357
14년 전 조회 1,592
14년 전 조회 2,888
14년 전 조회 2,849
14년 전 조회 3,847
14년 전 조회 1,968
14년 전 조회 2,097
14년 전 조회 1,635
14년 전 조회 1,711
14년 전 조회 2,945
14년 전 조회 1,732
14년 전 조회 3,238
14년 전 조회 1,441
14년 전 조회 4,343
14년 전 조회 1,519
14년 전 조회 2,887
14년 전 조회 4,306
14년 전 조회 1,565
14년 전 조회 1,742
14년 전 조회 2,120
14년 전 조회 1,623
14년 전 조회 2,174
14년 전 조회 2,049
14년 전 조회 2,170
14년 전 조회 1,924
14년 전 조회 1,524
14년 전 조회 1,990
14년 전 조회 1,998
14년 전 조회 1,848
14년 전 조회 1,433
14년 전 조회 1,384
14년 전 조회 1,786
14년 전 조회 1,281
14년 전 조회 3,876
14년 전 조회 1,314
14년 전 조회 1,715
14년 전 조회 1,348
14년 전 조회 1,384
14년 전 조회 2,632
14년 전 조회 1,686
14년 전 조회 2,138
14년 전 조회 1,420
14년 전 조회 1,986
14년 전 조회 2,507
14년 전 조회 1,577
14년 전 조회 2,037
14년 전 조회 1,559
14년 전 조회 1,943
14년 전 조회 3,383
14년 전 조회 1,428
14년 전 조회 5,584
14년 전 조회 1,409
14년 전 조회 1,594
14년 전 조회 1,438
14년 전 조회 4,159
14년 전 조회 1,237
14년 전 조회 1,582
14년 전 조회 1,881
14년 전 조회 1,885
14년 전 조회 1,366
14년 전 조회 1,996
14년 전 조회 1,455
14년 전 조회 1,341
14년 전 조회 2,988
14년 전 조회 1,750
14년 전 조회 1,325
14년 전 조회 1,314
14년 전 조회 2,348
14년 전 조회 1,532
14년 전 조회 1,922
14년 전 조회 1,905
14년 전 조회 2,516
14년 전 조회 2,582
14년 전 조회 1,852
14년 전 조회 1,476
14년 전 조회 1,415
14년 전 조회 1,647
14년 전 조회 1,849
14년 전 조회 3,293
14년 전 조회 1,309