luthier framework
Version 0.1.1
경고 : 개발 중!
Luthier Framework는 API 및 소규모 웹 사이트를 신속하게 구축하기위한 다양한 PHP 마이크로 프레임 워크입니다. 우리가 "마이크로"라고 말할 때 우리는 실제로 마이크로를 의미합니다. 실제로 작곡가와 단일 .php 파일 만 시작하려면 필요합니다.
작곡가로 Luthier 프레임 워크를 얻으십시오.
composer require luthier/framework
기본 예 : 예 :
<?php
# your_app/index.php
require ' vendor/autoload.php ' ;
$ app = new Luthier Framework ();
$ app -> get ( ' / ' , function (){
$ this -> response -> write ( " Hello world! " );
});
$ app -> group ( ' api ' , function (){
$ this -> get ( ' / ' , function (){
json_response ([ ' message ' => ' Welcome to Luthier Framework! ' ]);
});
$ this -> get ( ' about ' , function (){
json_response ([ ' version ' => Luthier Framework:: VERSION ]);
});
});
$ app -> run (); 경로 정의 :
$ app -> get ( ' foo/ ' , function (){
// Default template engine (will search for /foo.php file)
view ( ' foo ' );
});
$ app -> post ( ' bar/ ' , function (){
view ( ' bar ' );
});
$ app -> match ([ ' get ' , ' post ' ], ' baz/ ' , function (){
view ( ' baz ' );
}); 라우터 매개 변수 :
$ app -> get ( ' hello/{name} ' , function ( $ name ){
$ this -> response -> write ( " Hello $ name ! " );
});
// Optional parameters
$ app -> get ( ' about/{category?} ' , function ( $ category = ' animals ' ){
$ this -> response -> write ( " Category: category " );
});
// Regex parameters
$ app -> get ( ' website/{((en|es|fr)):lang} ' , function ( $ lang ){
$ this -> response -> write ( $ lang );
}); 노선 미들웨어 :
// Global middleware:
$ app -> middleware ( function ( $ request , $ response , $ next ){
$ response -> write ( ' Global <br> ' );
$ next ( $ request , $ response );
});
// Global middleware (but not assigned to any route yet)
$ app -> middleware ( ' test ' , function ( $ request , $ response , $ next ){
$ response -> write ( ' Before route<br> ' );
$ next ( $ request , $ response );
$ response -> write ( ' After route <br> ' );
});
$ this -> get ( ' / ' , function (){
$ this -> response -> write ( ' Route <br> ' )
})-> middleware ( ' test ' ); // <- assign the 'test' middleware to this route
곧 올 것입니다!
당신이 우리의 일을 사랑한다면, Patreon에서 우리를 지원하는 것을 고려하십시오