Extend Request class in Laravel 5

后端 未结 6 1395
猫巷女王i
猫巷女王i 2020-12-08 22:48

I\'m new to Laravel (only experienced Laravel 5, so no legacy hang up here)

I\'d like to know how to extend the core Request class. In addition to how to extend it,

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 23:10

    Here is Official Document: Request Lifecycle

    Content of app/Http/CustomRequest.php

    add this line to public/index.php

    $app->alias('request', 'App\Http\CustomRequest');
    

    after

    app = require_once __DIR__.'/../bootstrap/app.php';
    

    change the code at public/index.php

    Illuminate\Http\Request::capture()
    

    to

    App\Http\CustomRequest::capture()
    

提交回复
热议问题