Composer更新打破了网站Laravel 5.2
我不小心运行了composer update,它破坏了我的网站。我使用的是Laravel5.2。现在,我得到了这个错误Composer更新打破了网站Laravel 5.2,laravel,composer-php,Laravel,Composer Php,我不小心运行了composer update,它破坏了我的网站。我使用的是Laravel5.2。现在,我得到了这个错误 ErrorException in EventServiceProvider.php line 8: Declaration of App\Providers\ EventServiceProvider::boot(Illuminate\Contracts\Events\ Dispatcher $events) should be compatible with
ErrorException in EventServiceProvider.php line 8:
Declaration of
App\Providers\
EventServiceProvider::boot(Illuminate\Contracts\Events\ Dispatcher $events) should be compatible with
Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()
我尝试像这样从EventServiceProvider中删除参数
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot()
{
parent::boot();
//
}
更改前的EventServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as
ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as
ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
更改前的RouteServiceProvider:
<?php
namespace App\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as
ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
'App\Events\SomeEvent' => [
'App\Listeners\EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
<?php
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as
ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
根据评论和讨论,您最终将Laravel框架更新到了5.3.31,这与5.2有着突破性的变化。解决方案可能是降级到5.2下的最新版本,或者按照升级指南将整个应用程序升级到5.3
要解决降级问题,请将composer.json
中的当前框架包替换为“laravel/framework”:“5.2.*”,
并运行composer update
laravel的当前版本和以前版本(如果您记得的话)?同时发布完整的EventServiceProvider.php
,更新后没有更改。我已经编辑了问题,请检查我需要查看完整的类,而不仅仅是引导方法。我可能知道问题是什么。我需要确认一下,对不起。我刚刚编辑了它。请检查您是否可以从vendor/laravel/framework/src/illumb/Foundation/Application.php
检查框架版本并发布?它应该类似于const VERSION='5.4.23'代码>。从5.2分支的角度来看,我认为您的提供商没有任何问题。该解决方案工作得非常好。非常感谢。你救了我一天。