How to extend Router on Laravel5

在网上找到一个可行的办法, 虽然粗糙了一些, 但是简单有效:

First I need to extend the core application :

<?php namespace App\Services;
use Illuminate\Events\EventServiceProvider;
class Application extends \Illuminate\Foundation\Application {
    /**
     * Register all of the base service providers.
     *
     * @return void
     */
    protected function registerBaseServiceProviders()
    {
        $this->register(new EventServiceProvider($this));
        $this->register(new \App\Providers\RoutingServiceProvider($this));
    }
}

So in bootstrap :

$app = new App\Services\Application(realpath(__DIR__.'/../'));

I extend the RoutingServiceProvider :

<?php namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class RoutingServiceProvider extends \Illuminate\Routing\RoutingServiceProvider {
    /**
     * Register the router instance.
     *
     * @return void
     */
    protected function registerRouter()
    {
        $this->app['router'] = $this->app->share(function($app)
        {
            return new \App\Services\Router($app['events'], $app);
        });
    }
}

And a last my router :

<?php namespace App\Services;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Routing\Router as BaseRouter;
class Router extends BaseRouter {

    public function __construct(Dispatcher $events)
    {
        parent::__construct($events);
    }
    ...
}