PHP artisan suddenly doesn't work

DarioBB picture DarioBB · Aug 25, 2015 · Viewed 9.3k times · Source

I have started to learn Laravel. Until now, everything worked perfectly. I'm following this tutorial and I'm stuck with episode 7.

The problem is that I cannot start artisan anymore. I have tried to install tinker, and I've probably updated artisan so I ended up without artisan and tinker. I am using Linux Ubuntu 12.04 LTS. I have installed everything via command line. After that I tried to run:

php artisan --version

The following problem occurs:

[ErrorException]
Declaration of App\Providers\EventServiceProvider::boot() should be compati ble with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot
()

This is how my file app/Providers/EventServiceProvider.php looks like:

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

        //
    }
}

I'm using Laravel 5.2 and my composer.json it looks like this:

"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"doctrine/dbal": "^2.6@dev",
"vluzrmos/tinker": "dev-master",
"moon/artisan": "dev-master"

I've seen similar problems here for example:

https://laracasts.com/discuss/channels/general-discussion/l5-composer-update-ends-with-an-error-suddenly

https://laracasts.com/discuss/channels/laravel/event-service-provider-in-package

but never the answer was given directly and actually I do not understand how to solve this problem? I would need direct answer because I'm newbie in Laravel. Can artisan be updated somehow easy with Linux command line so it can work again?

Answer

greut picture greut · Aug 9, 2016

Apparently, the new boot() method doesn't take any argument. You'll have to apply some changes to the three providers.

     /**
      * Register any other events for your application.
      *
-     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
      * @return void
      */
-    public function boot(DispatcherContract $events)
+    public function boot()
     {
-        parent::boot($events);
+        parent::boot();

         //
     }

Check out this commit for the full list of changes.

https://github.com/laravel/laravel/commit/2b05ce3b054593f7622c1be6c4c6aadc1c5a54ae