mercredi 12 juillet 2017

Class 'Pusher' not found

When I install Pusher package, I got an error "Class 'Pusher' not found".

After researching, I finally fix this issue.

I created this command like this

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


And remember to add "php artisan fix:pusher" to composer.json file

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



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2uh2CBb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire