Php Laravel如何使PackageRouteServiceProvider与5.2和5.3兼容?
RouteServiceProvider->boot()方法的签名已从更改为Php Laravel如何使PackageRouteServiceProvider与5.2和5.3兼容?,php,laravel-5.2,laravel-5.3,Php,Laravel 5.2,Laravel 5.3,RouteServiceProvider->boot()方法的签名已从更改为 public function boot(Router $router) { parent::boot($router); } 到 我需要更新一个为5.2实现的包,使其与5.2和5.3兼容。我该怎么做呢?我以前从未使用过软件包 如果删除该参数,则会出现5.2中的下一个错误: PackageNS\RouteServiceProvider::boot()的声明应与Illumb\Foundation\Support
public function boot(Router $router)
{
parent::boot($router);
}
到
我需要更新一个为5.2实现的包,使其与5.2和5.3兼容。我该怎么做呢?我以前从未使用过软件包
如果删除该参数,则会出现5.2中的下一个错误:
PackageNS\RouteServiceProvider::boot()的声明应与Illumb\Foundation\Support\Providers\RouteServiceProvider::boot(Illumb\Routing\Router$Router)兼容
如果我保留它,它将返回5.3中类似的错误:
PackageNS\RouteServiceProvider::boot(Illumb\Routing\Router$Router)的声明应与Illumb\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';
});
}
}
我的建议是:不要将核心Laravel服务提供商扩展到一个可能在不同Laravel版本中使用的包中。你能展示一下你的
服务提供商的内容吗,因为可能有一种方法可以将其抽象出来,使其发挥作用。当然可以。它在编辑中。
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';
});
}
}