2017-07-07 5 views
1

私はlaravel 5.4とTelegram Bot SDKを使用しています。電報Bot SDK addコマンド

私のボットにコマンドを追加したいと思います。

StartCommandを​​に追加しようとしましたが、エラーが発生します。

Command class "Vendor\App\Commands\StartCommand" not found! 

が、ドキュメントは言う:

あなたがいる限り、あなたのコマンドは、あなたのcomposer.json設定

に基づいて自動的にロードすることができ、私はStartCommand classを格納して任意のディレクトリにカスタムコマンドを格納することができます。 app\StartCommand.phpにあります。

は、ここに私のcomposer.jsonです:で

... 
, 
"autoload": { 
    "classmap": [ 
     "database" 
    ], 
    "psr-4": { 
     "App\\": "app/" 
    } 
}, 
... 
ここ

あるtelegrom-BOT-SDKの設定の `config \ telegram.php:

... 
    'commands' => [ 
     Telegram\Bot\Commands\HelpCommand::class, 
     Vendor\App\Commands\StartCommand::class, 
    ], 
]; 

答えて

1

私は私のファイルの現在の名前空間を使用する必要があります。

私はapp\でコマンドファイルを保存する場合は、私が代わりに

namespace Vendor\App\Commands; 

config\telegram.phpでの私のコードで

namespace App; 

を使用する必要があります。

... 
    'commands' => [ 
     Telegram\Bot\Commands\HelpCommand::class, 
     App\StartCommand::class, 
    ], 
]; 
関連する問題