Nexmo / nexmo-laravel

Add Vonage functionality such as SMS and voice calling to your Laravel app with this Laravel Service Provider.
MIT License
317 stars 79 forks source link

Can't find Nexmo/Client in a job #26

Closed sburkett closed 6 years ago

sburkett commented 6 years ago

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 6 years ago

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

sburkett commented 6 years ago

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

    }
}
sburkett commented 6 years ago

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.

sburkett commented 6 years ago

Right now, I am getting:

Class 'App\Jobs\Client' not found

mheap commented 6 years ago

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

sburkett commented 6 years ago

Cool let me take a look.

sburkett commented 6 years ago

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