如何在Laravel中扩展Illuminate \ Routing \ Route? [英] How to extend Illuminate\Routing\Route in laravel?
本文介绍了如何在Laravel中扩展Illuminate \ Routing \ Route?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要扩展Illuminate \ Routing \ Route并以这种方式使用它:
I want extend Illuminate\Routing\Route and use it in this way:
request()->someCustomFunction();
有什么建议吗?
推荐答案
您可以编写自己的扩展Illuminate\Routing\Route
的类,并在服务提供者中编写n,您可以像这样绑定它:
You can write your own class that extends Illuminate\Routing\Route
and the n in your service provider you can bind it like this:
public function register()
{
$this->app->bind('Illuminate\Routing\Route', 'YourClassThanExtendsRoute');
}
这应该可行.
这篇关于如何在Laravel中扩展Illuminate \ Routing \ Route?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文