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

PaulClarke's avatar

Update to Laravel 5.3 broken ServiceProviders cannot deploy to Forge

Dear All,

I've recently tried to update my project to Laravel 5.3 / PHP 7. Locally things work. When I try and deploy to Forge I get an error. (Nope: I am a pretty inexperienced programmer with just a few months under my belt, so have probably done something foolish when following the update instructions, so any help/guidance would be much appreciated).

The error: Declaration of Gordian\Providers\EventServiceProvider::boot() should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events)

I have checked both boot methods and neither accepts a parameter. To be sure I got the code direct from the Laravel Github repository.

I am having the same problem with the Route & Broadcast Providers.

My Providers now look as follows:

namespace Gordian\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 = [ 'Gordian\Events\SomeEvent' => [ 'Gordian\Listeners\EventListener', ], ]; /* * Register any events for your application. * * @return void */ public function boot() { parent::boot(); // } }

And in the Illuminate folder...

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

}

Any help you can provide would be gratefully received!

0 likes
4 replies
bobbybouwmann's avatar

It looks like you didn't updated your composer.json file or your deployment is using the composer.lock file. Make sure your server is using Laravel 5.3 as well.

So make sure you run composer install first using the update composer.json file.

PaulClarke's avatar

Thanks for the reply Bobby.

I have now tried that to no avail and done some reading up on composer.lock (https://daylerees.com/the-composer-lock-file/) but no joy. The composer.lock and composer.json file exactly the same on my local version as on my server. I've run php artisan --version on both and both respond with 5.3 but ONLY when I comment out the lines from my config/app as shown below. If reference is made to either ServiceProvider then my app won't load locally either and php artisan stops working (no command will run at all, it just throws a FatalError).

Config/App:

    /*
     * Application Service Providers...
     */
    Gordian\Providers\AppServiceProvider::class,
    Gordian\Providers\AuthServiceProvider::class,
    Gordian\Providers\EventServiceProvider::class,

// Gordian\Providers\BroadcastServiceProvider::class, // Gordian\Providers\RouteServiceProvider::class,

Error when trying to run artisan command:

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Pusher' not found

(I tried composer require pusher/pusher-php-server in case it was that, but no difference there either).

PaulClarke's avatar

I have things finally working again. It looks like there were a number of things I'd done wrong and I have to confess I am not entirely sure which action got things going again. In case it helps anyone else, here is what I did:

  1. Looks like I have created the new BroadcastServiceProvider by just making a class in the folder, rather than using the artisan command line. So re-did that correctly.

  2. Some dependencies appear not to have been installed into 'Illuminate/Routing/Router.php' e.g. use Psr\Http\Message\ResponseInterface as PsrResponseInterface; use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;

So I ran composer require symfony/psr-http-message-bridge

  1. Next there was a problem with the Auth. I was using a named route 'logout' in my view. Of course 5.3 changed logout to a POST method and removed the named route I had attached.

I followed the guidance here when converting the route to POST https://github.com/laravel/framework/blob/7d116dc5a008e69c97f864af79ac46ab6a8d5895/src/Illuminate/Auth/Console/stubs/make/views/layouts/app.stub

  1. I set up a new temporary Forge/DigitalOcean server and everything worked (yay!) but things still did not work on my original Forge server. So in the end I just the destroyed the original broken one replaced with my new local working version and restored the database.

Like I say, not sure which thing initial was done wrong to create the raft of errors so apologies if the answer isn't especially useful to anyone. Any thank you to Bobby for responding.

bobbybouwmann's avatar

Glad you fixed it ;) If you have more questions you know where to find me ;)

Please or to participate in this conversation.