Laravel
MVC,ADR
ADR
コントローラーがレスポンダーを返す
エラーハンドラー
ExceptionランタイムとViewを紐づけできる
無いもしないとエラーハンドラーが呼び出される
Route
でrestとControllerの紐づけ
Kernel
Guard
EmailValidator
Email用のライブラリをuseしている
UnitTestは基本Httpリクエストなのか。
code:test
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
laravelクリーンアーキテクチャ
facade
スーパークラスの__callStaticメソッドを呼び出し、対象のインスタンスを取得し、指定メソッドを実行する
ドメイン駆動
ルールのカスタマイズ
そして、そのインスタンスのfailsメソッドの結果によって、例外が投げらます。 次に、Laravelは投げられた例外に応じて様々な処理を自動で行うようになっているので、この場合は送信元のフォームへリダイレクトしてくれます。その際に、入力された内容や、エラーのメッセージを保持する処理が施されているので、エラーの表示や、元の入力値の復元などを実現することができるのです。
code:validate
$this->validate($request, [
'name' => 'required|alpha',
'level' => 'required|numeric|between:1,99',
]);
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
ログイン周り
code:login.resetpassword.php
protected function resetPassword($user, $password)
{
$user->password = Hash::make($password);
$user->setRememberToken(Str::random(60));
$user->save();
event(new PasswordReset($user));
$this->guard()->login($user);
}
code:php
public function createTokenDriver($name, $config)
{
// The token guard implements a basic API token based guard implementation
// that takes an API token field from the request and matches it to the
// user in the database or another persistence layer where users are.
$guard = new TokenGuard(
$this->createUserProvider($config'provider' ?? null), );
$this->app->refresh('request', $guard, 'setRequest');
return $guard;
}
認証
OAuth2.0に対応しているようだが、OIDCと明示的に対応していなさそう
Authentication