[英]"Class 'Nexmo\\Laravel\\Facades\\Nexmo' not found" Error
I am trying to send an sms once a user signs up but it keep getting:我试图在用户注册后发送短信,但它不断收到:
"Class 'Nexmo\\Laravel\\Facades\\Nexmo' not found"
I have this at the top of my controller file:我在我的控制器文件的顶部有这个:
use Nexmo\Laravel\Facades\Nexmo;
I also have this in my config/app.php
file我的
config/app.php
文件中也有这个
'Nexmo' => Nexmo\Laravel\Facades\Nexmo::class,
Im still getting an error, does anyone or has the same problem.我仍然遇到错误,有没有人或有同样的问题。 I know its a class type error but why if I have added the right class and im using it appropriately.
我知道这是一个类类型错误,但如果我添加了正确的类并正确使用它,为什么会这样。
Also, here is my code implementation:另外,这是我的代码实现:
Nexmo::message()->send([
'to' => '1122334455', //not actually using this number
'from' => 'Test',
'text' => 'Hey, test this digit code',
'text' => $request->user()->activation_token
]);
Update 1: I have done php artisan vendor:publish
and published the nexmo config file but it sill gives the error above.更新 1:我已经完成了
php artisan vendor:publish
并发布了 nexmo 配置文件,但它仍然会出现上述错误。
Add Nexmo\\Laravel\\NexmoServiceProvider to the providers array in your config/app.php: 将Nexmo \\ Laravel \\ NexmoServiceProvider添加到config / app.php中的providers数组中:
'providers' => [
// Other service providers...
Nexmo\Laravel\NexmoServiceProvider::class,
],
Thanks guys for answers/suggestions 谢谢大家的回答/建议
Some reason it is working now? 现在可以正常工作的某些原因? I did all the suggestions/answers and it did not work, did some other stuff (not working on this) and it suddenly works?
我完成了所有建议/答案,但没有用,是否有其他内容(在此方面无用),却突然起作用了?
Thanks guys :) 多谢你们 :)
If I found out what I did to make it work I will update this answer. 如果我发现要使它起作用,我会更新此答案。
Found the answer: Found out when I run php artisan vendor:publish
it gives a list to publish or something and i'm guessing I did not do the one that specifically publishes Nexmo. 找到了答案:当我运行
php artisan vendor:publish
时发现了它,它给出了要发布的列表或其他内容,我想我没有做专门发布Nexmo的列表。 Still should've worked though because I did the one that will publish everything. 不过仍然应该工作,因为我做了将发布所有内容的工作。 Anyways that published the Nexmo file in
config
folder. 无论如何,在
config
文件夹中发布了Nexmo文件。 Somehow that is what made everything else work, that and probably a combination of answer/suggestions 不知何故,这使其他所有内容都起作用,并且可能是答案/建议的组合
Anyways thanks guys for your help!! 无论如何,谢谢你们的帮助!
First of all, the Nexmo documentation did not mention about to use with Laravel but there are as a additional package you need to use if you used with Laravel .首先, Nexmo文档没有提到与Laravel一起使用,但如果与Laravel一起使用,则需要使用一个额外的包。
There are are a simple solution.You need to install a additional package that already provide by Nextmo to use with Laravel .Just install below one.I hope this will help u.有一个简单的解决方案。您需要安装 Nextmo 已经提供的附加软件包才能与Laravel一起使用。只需安装下面一个。我希望这对您有所帮助。
composer require nexmo/laravel
try it尝试一下
$nexmo = app('Nexmo\Client');
$nexmo->message()->send([
'to' => 'yournumber',
'from' => 'yournumber',
'text' => "message"
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.