Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

stueynet's avatar

Laravel 5.3 update causing error on Forge only

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)  

Any help would be appreciated.

0 likes
21 replies
stueynet's avatar

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.

nate.a.johnson's avatar

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:

php artisan clear-cache
php artisan clear-compiled
etc... and
composer dump-autoload
etc...
joedawson's avatar

Have you run a composer update on your server to pull in 5.3?

1 like
stueynet's avatar

@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.

stueynet's avatar

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.

1 like
kunli0's avatar

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);
    }

NEW:

public function boot()
    {
        parent::boot();
    }
14 likes
stueynet's avatar

@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.

gluten's avatar

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.

15 likes
demandship's avatar

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.

Dario's avatar

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!

redenz's avatar

@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!

4 likes
ejdelmonico's avatar

Use a fresh install locally to compare files. It sounds like something is amiss. Additionally, make sure you use artisan to clear all caches.

php artisan route:cache
php artisan view:clear
php artisan config:clear
php artisan cache:clear
php artisan clear-compiled
php artisan optimize
php artisan route:cache

If you can't run artisan then the upgrade has something wrong besides caches.

NilsonLemos's avatar

@kunli0

Updated App\Providers\RouteServiceProvider and App\Providers\EventServiceProvider.

Ran php artisan cache:clear and now I am receiving this error:

[BadMethodCallException] Method controller does not exist.

Any idea of what this error might be?

EDIT: My bad. I was using implicit controllers and those were deprecated. Starting at 5.3 they don't work anymore.

drehimself's avatar

@redenz @gluten

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 :)

safiahmed4cs@gmail.com's avatar

I am still facing the issue upgrading from 5.2 to 5.3

@drehimself did you upgraded to 5.3?

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()

yoman's avatar

try

composer update --no-scripts
1 like
wturrell's avatar

Just to point out there's actually three classes you need to change, not two, as per the upgrade guide:

  • App\Providers\RouteServiceProvider
  • App\Providers\EventServiceProvider
  • App\Providers\AuthServiceProvider
ankitparmar372's avatar

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.

Check this guys : https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0

taffytech's avatar

@KUNLI0 - *You will need to repeat this change for any service providers

I searched for a solid 20 minutes for this. THANK YOU SO MUCH KUNLI0

Please or to participate in this conversation.