v

PHP ANOTATION , Reflection

· 14년 전 · 1427
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,142
14년 전 조회 2,394
14년 전 조회 1,921
14년 전 조회 2,944
14년 전 조회 1,598
14년 전 조회 1,614
14년 전 조회 1,438
14년 전 조회 2,263
14년 전 조회 1,859
14년 전 조회 1,594
14년 전 조회 6,146
14년 전 조회 2,722
14년 전 조회 1,977
14년 전 조회 1,482
14년 전 조회 1만
14년 전 조회 2,391
14년 전 조회 1,402
14년 전 조회 1,405
14년 전 조회 2,270
14년 전 조회 2,832
14년 전 조회 2,351
14년 전 조회 1,580
14년 전 조회 2,880
14년 전 조회 2,842
14년 전 조회 3,835
14년 전 조회 1,962
14년 전 조회 2,081
14년 전 조회 1,625
14년 전 조회 1,704
14년 전 조회 2,939
14년 전 조회 1,723
14년 전 조회 3,228
14년 전 조회 1,433
14년 전 조회 4,336
14년 전 조회 1,513
14년 전 조회 2,873
14년 전 조회 4,301
14년 전 조회 1,552
14년 전 조회 1,736
14년 전 조회 2,108
14년 전 조회 1,618
14년 전 조회 2,164
14년 전 조회 2,037
14년 전 조회 2,157
14년 전 조회 1,915
14년 전 조회 1,520
14년 전 조회 1,976
14년 전 조회 1,987
14년 전 조회 1,843
14년 전 조회 1,428
14년 전 조회 1,372
14년 전 조회 1,776
14년 전 조회 1,271
14년 전 조회 3,865
14년 전 조회 1,308
14년 전 조회 1,705
14년 전 조회 1,336
14년 전 조회 1,377
14년 전 조회 2,620
14년 전 조회 1,671
14년 전 조회 2,127
14년 전 조회 1,413
14년 전 조회 1,976
14년 전 조회 2,501
14년 전 조회 1,571
14년 전 조회 2,021
14년 전 조회 1,550
14년 전 조회 1,932
14년 전 조회 3,375
14년 전 조회 1,416
14년 전 조회 5,570
14년 전 조회 1,404
14년 전 조회 1,584
14년 전 조회 1,429
14년 전 조회 4,148
14년 전 조회 1,234
14년 전 조회 1,568
14년 전 조회 1,869
14년 전 조회 1,878
14년 전 조회 1,352
14년 전 조회 1,988
14년 전 조회 1,448
14년 전 조회 1,331
14년 전 조회 2,982
14년 전 조회 1,746
14년 전 조회 1,317
14년 전 조회 1,300
14년 전 조회 2,341
14년 전 조회 1,525
14년 전 조회 1,919
14년 전 조회 1,897
14년 전 조회 2,502
14년 전 조회 2,572
14년 전 조회 1,845
14년 전 조회 1,470
14년 전 조회 1,410
14년 전 조회 1,639
14년 전 조회 1,832
14년 전 조회 3,284
14년 전 조회 1,298