Class Pusher not found

When I install the Pusher package, I received an error message "Class" Pusher "not found."

+6
source share
4 answers

Claudio diagnostics are correct, Pusher namespace was added in version 3; but modifying Laravel files is not recommended.

It is best to create an alias in config/app.php. Under the "aliases" key, add this to the array in the "Third Party Aliases" section:

'Pusher' => Pusher\Pusher::class,
+23
source

(OP . , 3 pusher-php-server , use Pusher\Pusher.)

:

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

"php artisan fix:pusher" composer.json :

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

3 Pusher , Pusher\Pusher. .env, BROADCAST_DRIVER = pusher, . , , , :

'/Laravel//SRC//Broadcasting/BroadcastManager.php "

. Pusher\Pusher Pusher, : enter image description here

PusherBroadCaster Pusher\Pusher.

enter image description here

/Laravel//SRC//Broadcasting//PusherBroadcaster.php

+1

Just go in vendor/laravel/framework/src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.phpand change "Use Pusher" to "Use Pusher / Pusher";

0
source

All Articles