报错 PHP Error: Call to a member function getMessage () on null in Psy Shell code on line 4
这个报错是什么问题呢?EasySmsServiceProvider.php
代码如下:
<?php
namespace App\Providers;
use Overtrue\EasySms\EasySms;
use Illuminate\Support\ServiceProvider;
class EasySmsServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->app->singleton(EasySms::class, function ($app) {
return new EasySms(config('easysms'));
});
$this->app->alias(EasySms::class, 'easysms');
}
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
//
}
}
tinker报错信息如下:
$ php artisan tinker
Psy Shell v0.9.9 (PHP 7.1.16 — cli) by Justin Hileman
>>> $sms = app('easysms');
=> Overtrue\EasySms\EasySms {#3209}
>>> try {
... $sms->send(13888853427, [
... 'content' => ' Lbbs 1234 ',
... ]);
... } catch (\Overtrue\EasySms\Exceptions\NoGatewayAvailableException $exception) {
... $message = $exception->getException('yunpian')->getMessage();
... dd($message);
... }
PHP Error: Call to a member function getMessage() on null in Psy Shell code on line 4
推荐文章: