Lumen アプリケーション・フレームワーク
, (*1)
アプリケーションで必須の構成ResponseとExceptionをコンテナに登録する。, (*2)
内部構造
Exception Handler
ExceptionHandler はデフォルトをベースに、
render側では \Chatbox\LumenApp\RequestRendererInterface::renderException()に例外をPassするだけの対応, (*3)
例外処理に伴う切り分けの責務などは\Chatbox\LumenApp\RequestRendererInterfaceに委譲し、
ExceptionHandlerでは例外の切り替えを行うのみに徹する。, (*4)
\Chatbox\LumenApp\RequestRendererInterface
コンテンツ及び例外のRenderに関する一切の処理を司る。, (*5)
Middlewareから参照して全てのContents付きResponseを整形したり、, (*6)
受け取ったExceptionを処理してResponseに変換したりする。, (*7)
renderContent()
暗黙のコールを仕様に含まない。, (*8)
Middleware等でResponse処理の共通整形などをかける際に利用する。, (*9)
renderException()
ExceptionHandler内でコールされる。, (*10)
Usage
Service Provider を登録して利用, (*11)
$app->register(\Chatbox\LumenApp\LumenAppServiceProvider::class);
挙動の制御はコンテナ登録or書き換えを経由して行う。, (*12)
レスポンス周りを修正する場合はResponseFactoryInterface::classで修正。, (*13)
$app->singleton(ResponseFactoryInterface::class,function(){
return new APIResponse();
});