Nexmo/nexmo-laravel

Can't find Nexmo/Client in a job

Closed this issue · 7 comments

I must be missing the obvious. Probably been staring at this for too long! lol

I have a queueable job that I want to send an SMS via Nexmo. Installed nexmo/laravel on Laravel 5.5, so I'm assuming the Facade and provider were auto-discovered.

Whenever I try to use the Facade in my handle() method in the job, I keep getting this in the Laravel log:

Class 'App\Jobs\Nexmo\Client' not found

Any ideas? I've tried using use Nexmo;, et al, but no matter what I do, it just can't seem to find the class! Thanks in advance. Maybe I need more coffee ... or less. Who knows lol.

mheap commented

Hey @sburkett, it looks like you've done everything that you needed. Is the code available anywhere that I can take a look?

Sadly, no. Here is a snippet:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;

use Nexmo\Laravel\Facade\Nexmo;

class Foo implements ShouldQueue
{
...
    public function handle()
    {
      Nexmo::message()->send([
          'to' => $this->smsRecipient,
          'from' => $this->smsFrom,
          'text' => $this->smsMessage
      ]);

    }
}

The package is definitely auto-discovered per composer package:discover and composer dump-autoload ... and the official Nexmo PHP client is required in composer as well.

Right now, I am getting:

Class 'App\Jobs\Client' not found

mheap commented

I've just put together a small demo app to try and reproduce but it seems to be working fine. I can't see any difference between our jobs

https://github.com/mheap/laravel-queue-test/blob/master/app/Jobs/ProcessPodcast.php
https://github.com/mheap/laravel-queue-test/blob/master/routes/web.php

Cool let me take a look.

OMG ... I forgot to restart my queue listener. :D Works now ... sorry for bugging you over something so silly!