2017-11-28 12 views
0

ルーメンでプッシュ通知アプリケーションを開発するプロセスでは、通知を行うにはphp artisanコマンドを実行する必要があります。私が実行するときphp artisanmake:notificationphp artisan make:notification)コマンドは利用できません。次のエラーが表示されます。コマンド "make:notification"が定義されていません。 |ルーメン5.5

[Symfony\Component\Console\Exception\CommandNotFoundException] 

Command "make:notification" is not defined

Did you mean one of these? 
     make:migration 
     make:seeder 

この問題を解決するのを手伝ってください。 ありがとう

+0

私はルーメンのためにその機能がある場合...ルーメンはAPIフレームワークであることを確認していません。 Laravelではバージョン5.3以降の機能が存在すると私は思っています。 – lewis4u

+0

バージョン5.5を使用しています – CoolCK

+0

LaravelまたはLumen ??? – lewis4u

答えて

3

コマンドphp artisan make:notification NameOfNotificationルーメンに存在しません。

そのパッケージをインポートする必要があります。

出典:これはのために必要な依存関係であれば多分

composer require illuminate/notifications 

あなたは、私は100%ではないよrequire illuminate/supportます:https://stevethomas.com.au/php/using-laravel-notifications-in-lumen.html


が最初のステップが点灯/通知パッケージを必要としています通知。エラーが発生した場合、これが原因かもしれません。

次に、ブートストラップ/ app.php

にサービスプロバイダを登録
$app->register(\Illuminate\Notifications\NotificationServiceProvider::class); 

// optional: register the Facade 
$app->withFacades(true, [ 
    'Illuminate\Support\Facades\Notification' => 'Notification', 
]); 

ユーザーは明白ものであろう、あなたが好きな方のモデルに届出形質を追加します。

<?php 

namespace App; 

use Illuminate\Notifications\Notifiable; 

class User extends Model 
{ 
    use Notifiable; 
} 

書き込み通知通常の方法:

<?php 

namespace App\Notifications; 

use App\Spaceship; 
use Illuminate\Bus\Queueable; 
use Illuminate\Notifications\Notification; 
use Illuminate\Notifications\Messages\MailMessage; 

class SpaceshipHasLaunched extends Notification 
{ 
    use Queueable; 

    /** @var Spaceship */ 
    public $spaceship; 

    /** 
    * @param Spaceship $spaceship 
    */ 
    public function __construct(Spaceship $spaceship) 
    { 
     $this->spaceship = $spaceship; 
    } 

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

    /** 
    * Get the mail representation of the notification. 
    * 
    * @param mixed $notifiable 
    * @return \Illuminate\Notifications\Messages\MailMessage 
    */ 
    public function toMail($notifiable) 
    { 
     return (new MailMessage) 
      ->subject('Spacheship has launched!') 
      ->markdown('mail.spaceship', [ 
       'spaceship' => $this->spaceship 
      ]); 
    } 
} 

通常の方法で通知を送信します。

$user->notify(new Notifications\SpaceshipHasLaunched($spaceship)); 
+0

ハハかなり同じ記事を貼り付けました:D。とにかく私はupvoted :) – CoolCK

+1

それらはスタックオーバーフローのルールです。あなたが答えを出すときには、コードを提供するか説明する必要があります。リンクが壊れていても、質問だけを読むことで問題を解決できます。 – lewis4u

+0

あなたの助けをありがとう:) – CoolCK

関連する問題