mercredi 21 octobre 2020

Laravel "^6.18.35" “Target [Illuminate\Contracts\Bus\Dispatcher] is not instantiable.”

Im trying to test a job in laravel but with no success, when the job is called from a method inside a controller i get the following error: “Target [Illuminate\Contracts\Bus\Dispatcher] is not instantiable.”

I already tried AltThree Bus command as an alternative.

Controller method where thw job is called

  public function onOpen(ConnectionInterface $conn) {
    // Store the new connection to send messages to later
    $this->clients->attach($conn);
    echo "New connection! ({$conn->resourceId})\n";
    Updates::dispatch();
}

Job Class

<?php
namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class Updates implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        echo "this is a update";
    }
}



Aucun commentaire:

Enregistrer un commentaire