Laravel 5.3升级 - BroadcastServiceProvider错误

时间:2017-01-13 05:44:00

标签: laravel laravel-5.3

我尝试从laravel 5.3升级5.2,我在php artisan clear-compiled

时遇到错误
  

Class App \ Providers \ BroadcastServiceProvider包含1个摘要   因此,必须声明为抽象或实现   其余方法(Illuminate \ Support \ ServiceProvider :: register)

但是,在我的本地环境升级时,我没有遇到过这样的问题。

config/broadcasting.php如下:

<?php
return [
    'default' => env('BROADCAST_DRIVER', 'log'),
    'connections' => [
        'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_KEY'),
            'secret' => env('PUSHER_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
        ],
        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
        ],
        'log' => [
            'driver' => 'log',
        ],
    ],
];

app/Providers/BroadcastServiceProvider.php如下:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;

class BroadcastServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Broadcast::routes();
        Broadcast::channel('App.User.{userId}', function ($user, $userId) {
            return (int) $user->id === (int) $userId;
        });
    }
}

.env如下:

CACHE_DRIVER=file
SESSION_DRIVER=file
#BROADCAST_DRIVER=pusher
PUSHER_KEY=someKey
PUSHER_SECRET=SomeSecrete
PUSHER_APP_ID=SomeId

我尝试将默认broadcasting driver设置为log,但似乎无效。

我正在运行的任何命令: php artisan cache:clearphp artisan config:clearphp artisan view:clearphp artisan clear-compiled,我面临同样的错误。

我也尝试使用composer dump-autoload,它运行正常,但之后如果我再次运行php artisan clear-compiled,那么也会遇到同样的错误。

请帮帮我。

2 个答案:

答案 0 :(得分:1)

看起来你并没有真正更新框架,因为Illuminate\Support\ServiceProvider::register方法存在于5.2而不是5.3中 仔细检查您的更新

答案 1 :(得分:1)

我已修复此错误,方法是先将artisan命令更新composerupgrade to laravel 5.3

命令是:

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

然后再做

composer update

升级到laravel 5.3时会解决上述错误。