Yii2 notification extension

First and foremost, I’m learning yii2. Here is my question, is anyone here comfortably using the yii2 tuyakhov notification extension? If so, i could use some help as i’m having a hard time setting it up. below is my code and the preceding error

            $notfication_text = 'New payment Received.';
            Yii::$app->Kiduchi->save_notification($_POST['client_id'], $notfication_text);

            //notifier instance
            $recipients = $_POST['client_id'];
            $notifications = 'New payment Received.';

            $notifier = new \tuyakhov\notifications\Notifier([
                'channels' => ['mail'],
            $notifier->send($_POST['client_id'], 'New payment Received.');

            //send mail notification
            $recipient = KfUsers::find()->select('email')->where(['id' => $_POST['client_id']])->one();
            $notification = new InvoicePaid($invoice);

I’m getting this error:- [error][yii\base\ErrorException:1] exception ‘yii\base\ErrorException’ with message ‘Call to a member function viaChannels() on string’ in C:\wamp64\www\sites\kf_development\vendor\tuyakhov\yii2-notifications\src\Notifier.php:89

Since am still learning the yii2 framework, i am not sure in which directory to put the Notification class any help on this is appreciated. Thanks in advance

Just a thought: Did you include the proper " use…" statement at the top of you page/file?

I’m not sure , but It should be something like this

$notifier = new \tuyakhov\notifications\Notifier([
    'channels' => 'mail' => [
          'class' => '\tuyakhov\notifications\channels\MailChannel',
          'from' => 'no-reply@example.com'

Try with out the ‘’ at the front. ‘tuyakhov’ may be registered as an alias by installation. the use statement may not be necessary since you are fully qualifying it.

1 Like

I suppose I did.