2017-07-12 28 views

Odpowiedz

1

(OP pisał następującą odpowiedź na pytanie Podstawowym problemem jest to, że wersja 3 pusher-php-server wprowadza nazw i tak teraz wymaga use Pusher\Pusher.).

Tworzenie polecenia:

namespace App\Console\Commands; 

use Illuminate\Support\Facades\File; 
use Illuminate\Console\Command; 

class FixPusher extends Command 
{ 

    /** 
    * The name and signature of the console command. 
    * 
    * @var string 
    */ 
    protected $signature = 'fix:pusher'; 

    /** 
    * The console command description. 
    * 
    * @var string 
    */ 
    protected $description = 'Fix Pusher namespace issue'; 

    /** 
    * Create a new command instance. 
    * 
    * @return void 
    */ 
    public function __construct() 
    { 
     parent::__construct(); 
    } 

    /** 
    * Execute the console command. 
    * 
    * @return mixed 
    */ 
    public function handle() 
    { 
     $broadcastManagerPath = base_path('vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php'); 
     $pusherBroadcasterPath = base_path('vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php'); 

     $contents = str_replace('use Pusher;', 'use Pusher\Pusher;', File::get($broadcastManagerPath)); 
     File::put($broadcastManagerPath, $contents); 

     $contents = str_replace('use Pusher;', 'use Pusher\Pusher;', File::get($pusherBroadcasterPath)); 
     File::put($pusherBroadcasterPath, $contents); 
    } 
} 

Następnie dodać "php artisan fix:pusher" do composer.json file:

"post-update-cmd": [ 
    "php artisan fix:pusher", 
    "Illuminate\\Foundation\\ComposerScripts::postUpdate", 
    "php artisan optimize" 
] 
0

w wersji 3 Pusher I R ealized, że zmienił się obszar nazw dla Pusher \ Pusher. Jeśli konfigurujesz przez kompozytora, gdy ustawisz .env, BROADCAST_DRIVER = pusher, pokazuje to błąd. Sprawdzeniu dziennika, można się dowiedzieć, gdzie jest proble, znajduje się w tym pliku:

„sprzedawca/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php”

. jest to konieczne, zmień odniesienia dla Pusher \ Pusher zamiast Pusher jak na obrazku: enter image description here

następnie dowiedzieć się funkcję PusherBroadCaster i zmienić Pusher odniesienia dla Pusher \Popychacz.

enter image description here

dostawcy/laravel/ramy/src/Oświetlenia/nadawania/Nadawcy/PusherBroadcaster.php

18

Claudio diagnoza jest poprawna, popychacz nazw dodano w wersji 3; ale zmiana plików Laravel nie jest zalecanym rozwiązaniem.

Lepszym sposobem jest utworzenie aliasu w config/app.php. W polu "Aliasy" dodaj to do tablicy w sekcji "Aliasy stron trzecich":

'Pusher' => Pusher\Pusher::class, 
Powiązane problemy