Laravel如何使包RouteServiceProvider与5.2和5.3兼容?

时间:2016-10-26 13:44:48

标签: php laravel-5.2 laravel-5.3

RouteServiceProvider-> boot()方法的签名已从

更改
public function boot(Router $router)
{
    parent::boot($router);
}

public function boot()
{
    parent::boot();
}

我需要更新为5.2实现的包以兼容5.2和5.3。我该怎么做呢?我之前从未使用过包裹。

如果删除参数,我会在5.2中得到下一个错误:

  

PackageNS \ RouteServiceProvider :: boot()的声明应该与Illuminate \ Foundation \ Support \ Providers \ RouteServiceProvider :: boot(Illuminate \ Routing \ Router $ router)兼容

如果我保留它,它会在5.3中返回类似的错误:

  

PackageNS \ RouteServiceProvider :: boot(Illuminate \ Routing \ Router $ router)的声明应该与Illuminate \ Foundation \ Support \ Providers \ RouteServiceProvider :: boot()兼容

任何形式的帮助将不胜感激。提前谢谢。

这是我服务提供商的内容:     

use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

Class RouteServiceProvider extends ServiceProvider
{

    protected $namespace = 'ProviderNS\Controllers';

    public function boot(Router $router)
    {
        parent::boot($router);
    }

    /**
     * Define the routes for the application.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    public function map(Router $router)
    {
        $router->group(['namespace' => $this->namespace], function($router)
        {
            require __DIR__.'/../Config/routes.php';
        });
    }


}

0 个答案:

没有答案