问题描述
我是 Laravel 的新手(只体验过 Laravel 5,所以这里没有遗留问题)
我想知道如何扩展核心请求类.除了如何扩展它之外,我想知道这样做是否是一个明智的设计决定.
我已经广泛阅读了文档(特别是关于注册服务提供者以及它提供 Facades 访问依赖项容器内的条目的方式) - 但我可以看到(并找到)没有办法替换 IlluminateHttpRequest 实例与我自己的
这里是官方文档:Request Lifecycle >
app/Http/CustomRequest.php 的内容
将此行添加到 public/index.php
$app->alias('request', 'AppHttpCustomRequest');之后
app = require_once __DIR__.'/../bootstrap/app.php';更改 public/index.php 中的代码
IlluminateHttpRequest::capture()到
AppHttpCustomRequest::capture()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, i'd like to know if it's a wise design decision to do so.
I've read through the documentation extensively (especially with regards to registering service providers and the manner in which it provides Facades access to entries within the dependency container) - but I can see (and find) no way to replace the IlluminateHttpRequest instance with my own
Here is Official Document: Request Lifecycle
Content of app/Http/CustomRequest.php
<?php namespace AppHttp;
use IlluminateHttpRequest as BaseRequest;
class CustomRequest extends BaseRequest {
// coding
}
add this line to public/index.php
$app->alias('request', 'AppHttpCustomRequest');
after
app = require_once __DIR__.'/../bootstrap/app.php';
change the code at public/index.php
IlluminateHttpRequest::capture()
to
AppHttpCustomRequest::capture()
这篇关于在 Laravel 5 中扩展请求类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)