如何在laravel中扩展Illuminate \ Routing \ Route?

I want extend Illuminate\Routing\Route and use it in this way:

request()->someCustomFunction();

any suggests ?

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');
 }

This should works.

The solution is more a hack since Laravel 5 where it became more difficult to extend the default router. All you need is to add the following into your bootstrap file.

$app->singleton('router', \App\Services\Router::class);

Your new router stored in App/Services/Router.php will look like:

namespace App\Services;

class Router extends \Illuminate\Routing\Router
{
    public function someCustomFunction() {
    }
}

Then you will be able to do:

Router::someCustomFunction();

This solution was discussed in Laravel forums here