Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel通知不可解析的依赖项_Php_Laravel_Twitter_Laravel 5_Notifications - Fatal编程技术网

Php Laravel通知不可解析的依赖项

Php Laravel通知不可解析的依赖项,php,laravel,twitter,laravel-5,notifications,Php,Laravel,Twitter,Laravel 5,Notifications,我正在尝试将安装到使用Laravel5.3和PHP7.1的应用程序中。我已经创建了最简单的测试(转到/tweet路由并向第一个用户发送通知)来验证它是否正常工作。相反,我得到了以下错误: 无法解析的依赖项解析[参数#0[ $consumerKey]]在类Abraham\TwitterOAuth\TwitterOAuth中 我读到这篇文章是因为Laravel的IoC不知道传递什么,因为构造函数(我猜是包的)没有类型暗示。由于这是一个软件包,我不确定解决这个问题的最佳方法。我可以覆盖通知类中的构造函

我正在尝试将安装到使用Laravel5.3和PHP7.1的应用程序中。我已经创建了最简单的测试(转到/tweet路由并向第一个用户发送通知)来验证它是否正常工作。相反,我得到了以下错误:

无法解析的依赖项解析[参数#0[ $consumerKey]]在类Abraham\TwitterOAuth\TwitterOAuth中

我读到这篇文章是因为Laravel的IoC不知道传递什么,因为构造函数(我猜是包的)没有类型暗示。由于这是一个软件包,我不确定解决这个问题的最佳方法。我可以覆盖通知类中的构造函数吗?下面是我的考试通知课

<?php

namespace app\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

use NotificationChannels\Twitter\TwitterChannel;
use NotificationChannels\Twitter\TwitterMessage;

class TweetNotification extends Notification
{
    use Queueable;

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

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [TwitterChannel::class];
    }

    public function toTwitter($notifiable) {
        return new TwitterStatusUpdate('Laravel notifications are awesome!');
    }
}

我将在AppServiceProvider的register方法中绑定依赖项接口。看看这里:

不需要这样做,因为这里没有实现任何接口。您知道$consumerKey的类型吗?您还可以绑定具体的实现或静态实例,而不仅仅是接口。从包中,$consumerKey只是.env文件.Hmm中的一个字符串,因此查看该包中的服务提供商,它应该解决身份验证依赖关系。您是否已将packages config文件发布到config/目录并添加了非空值?您还应包括为测试此功能而编写的代码。