Since updating to 5.3 I am getting this error on deployment to forge only. This does not happen in my local homestead environment.
Declaration of App\Providers\EventServiceProvider::boot() should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events)
Just thought I would follow up. Here is my service provider.
namespace App\Providers;
use Illuminate\Support\Facades\Event;
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 events for your application.
*
* @return void
*/
public function boot()
{
parent::boot();
//
}
}
And here is the one built into Laravel
namespace Illuminate\Foundation\Support\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [];
/**
* The subscriber classes to register.
*
* @var array
*/
protected $subscribe = [];
/**
* Register the application's event listeners.
*
* @return void
*/
public function boot()
{
foreach ($this->listens() as $event => $listeners) {
foreach ($listeners as $listener) {
Event::listen($event, $listener);
}
}
foreach ($this->subscribe as $subscriber) {
Event::subscribe($subscriber);
}
}
/**
* {@inheritdoc}
*/
public function register()
{
//
}
/**
* Get the events and handlers.
*
* @return array
*/
public function listens()
{
return $this->listen;
}
}
They look compatible to me so I am at a loss. Again this is only on forge. Not locally.
You might want to clear up the cache, compiled, etc in both your local environment and forge to make sure you are seeing things the same way in both places:
@JoeDawson the server has the correct package versions. I run update locally which updates composer.lock. That is pushed up as its tracked in version control.
Hey all. Just to prove its an issue with Forge, I spun up a brand new site on the same DO box using forge and pulled in the same repo and it deployed no problemo. So it must be some weird caching thing happening on my current forge site. If I cannot get any help I will just rebuild the site from scratch. Only takes 3 minutes on forge anyway.
It seems these functions have changed to no longer require parameters. I ran into this same issue when upgrading the Framework from 5.2 to 5.3. There appears to be some other changes as well of which I am still figuring out.
In App\Providers\RouteServiceProvider change the following:
OLD
public function boot(Router $router)
{
parent::boot($router);
}
NEW
public function boot()
{
parent::boot();
}
And change App\Providers\EventServiceProvider:
OLD:
public function boot(DispatcherContract $events)
{
parent::boot($events);
}
@kunli0 in my case all of the changes were correctly made. I have proven this be easily installing the codebase and deploying on a new forge site. Also uninstalled the repository and re installed and it works just fine. This seems to be a bug with Forge and I imagine it is related to how vendor files get cached. Luckily it seems it is not really happening to anyone but me.
Actually I encountered the same problem without using Forge while performing the upgrade to 5.3, you need to get rid of bootstrap/cache and as you mentioned artisan won’t launch because of that error so you need to do it the old way: `rm -R bootstrap/cac and then `mkdir bootstrap/cac. Don’t forget to apply the correct permissions of bootstrap/cache after you’re done.
In your deploy script, are you running composer install after you run dump-autoload?
Your deploy script may generate this error before ever running composer install which means your packages are never updated. You can make sure by checking the vendor EventServiceProvider on your Forge Server.
Just change :
this "App\Providers\EventServiceProvider::boot(Dispatcher $events) "
with the new Service Provider not using the dependency anymore like this" App\Providers\EventServiceProvider::boot() "
and run "composer update" again.
Cheers!
@gluten's solution worked for me. Instead of removing bootstrap folder completely I just removed the 2 files in bootstrap/cache and I'm back to running. Thanks!
Thank you! Your solution worked as I was encountering the exact same issues as @stueynet. Hopefully, this is fixed in Forge by the time we update from 5.3 -> 5.4 :)
if it is then what changes you made in the files as i am facing following error
Declaration of App\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events) should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()
You may remove the arguments from the boot method on the EventServiceProvider, RouteServiceProvider, and AuthServiceProvider classes. Any calls to the given arguments may be converted to use the equivalent facade instead. So, for example, instead of calling methods on the $dispatcher argument, you may simply call the Event facade. Likewise, instead of making method calls to the $router argument, you may make calls to the Route facade, and instead of making method calls to the $gate argument, you may make calls to the Gate facade.