在Laravel中的Vinelab/minion中获取无效提供程序异常


Getting Invalid Provider Exception in Vinelab/minion in Laravel

我使用Vinelab/minion插件从server ( Laravel 4.2 )获得client app ( angularjs )中的通知,我在客户端实现了autobahn.js,但当我在Laravel中实现Vinelab/minion库并试图通过调用php artisan minion:run来运行minion时,会出现类似的错误

[Vinelab'Minion'InvalidProviderException]
 Provider Vinelab'Minion'ChatProvider must be an instance of 'Vinelab'Minion'Provider

我的目录结构:

app/
 config/
  packages/
   vinelab/
    minion/
     minion.php
 providers/
  ChatProvider.php
vendor/

和在app/config/packages/vinelab/minion/minion.php

<?php
return [
    /*
    |--------------------------------------------------------------------------
    | Router Realm
    |--------------------------------------------------------------------------
    |
    | The realm that the router should use.
    |
    */
    'realm' => 'minion',
    /*
    |--------------------------------------------------------------------------
    | Router Host
    |--------------------------------------------------------------------------
    |
    | The IP or hostname that the router should run under.
    |
    */
    'host' => '127.0.0.1',
    /*
    |--------------------------------------------------------------------------
    | Router Port
    |--------------------------------------------------------------------------
    |
    | The port that should be used by the router.
    |
    */
    'port' => 9090,
    /*
    |--------------------------------------------------------------------------
    | Auto-registered Providers
    |--------------------------------------------------------------------------
    |
    | The providers listed here will be automatically registered on the
    | session start of the router, in return their role is to register RPCs,
    | subscribe and publish to topics and pretty much whatever an Internal Client does.
    |
    */
    'providers' => [
        'ChatProvider'
    ],
    'debug' => true,
];

以及providers/ChatProvider.php

<?php
use Vinelab'Minion'Provider;
class ChatProvider extends Provider {
    protected $prefix = 'order.';
    public function boot()
    {
        // will be registered to topic: chat.send
        $this->register('send', 'sendMessage');
    }
    public function sendMessage($args, $data)
    {
        $message = $data->message;
        // store message in the database
        // tell everyone about it
        $this->publish('message', compact('message'));
        // response with the status
        return true;
    }
    }
}

我检查了各种名称空间和很多东西,但我无法解决这个问题。

我也在github上发布了这个问题,但没有找到任何答案。

这是完美的还是其他方式?

帮帮我,我们将不胜感激。

这是我的扩展类。

<?php
namespace Chaospower'Messaging'Provider;
use Vinelab'Minion'Provider;
use Auth;
class ChatProvider extends Provider
{
    protected $prefix = 'com.';
    public function boot()
    {
        // will be registered to topic: chat.send
        $this->register(Config::get('site.domain').'.message', 'sendMessage');
    }
    public function setPrefix($prefix)
    {
        $this->prefix = $prefix;
    }
    public function sendMessage($args, $data)
    {
        $message = $data->message;
        // store message in the database?
        // tell everyone about it
        $this->publish('message', compact('message'));
        // response with the status
        return true;
    }
}

我想您在某个地方丢失了命名空间。因为错误指向Vinelab''Minion''ChatProvider。它必须是namespace''ChatProvider。

输出应低于

vagrant@homestead:~/Code/Laravel$ php artisan minion:run --register="Chaospower'Messaging'Provider'ChatProvider"
           ▄▄▄▄▄▄▄▄▄▄▄▄▄
        ▄▀▀═════════════▀▀▄
       █═══════════════════█
      █═════════════════════█
     █═══▄▄▄▄▄▄▄═══▄▄▄▄▄▄▄═══█
    █═══█████████═█████████═══█
    █══██▀    ▀█████▀    ▀██══█
   ██████  █▀█  ███  █▀█  ██████
   ██████  ▀▀▀  ███  ▀▀▀  ██████
    █══▀█▄    ▄██ ██▄    ▄█▀══█
    █════▀█████▀   ▀█████▀════█
    █═════════════════════════█
    █═════════════════════════█
    █═══════▀▄▄▄▄▄▄▄▄▄▀═══════█
    █═════════════════════════█
   ▐▓▓▌═════════════════════▐▓▓▌
   ▐▐▓▓▌▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▐▓▓▌▌
   █══▐▓▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄▓▌══█
  █══▌═▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌═▐══█
  █══█═▐▓▓▓▓▓▓▄▄▄▄▄▄▄▓▓▓▓▓▓▌═█══█
  █══█═▐▓▓▓▓▓▓▐██▀██▌▓▓▓▓▓▓▌═█══█
  █══█═▐▓▓▓▓▓▓▓▀▀▀▀▀▓▓▓▓▓▓▓▌═█══█
  █══█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█══█
 ▄█══█▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌█══█▄
 █████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ █████
 ██████▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌ ██████
  ▀█▀█  ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌   █▀█▀
         ▐▓▓▓▓▓▓▌▐▓▓▓▓▓▓▌
          ▐▓▓▓▓▌  ▐▓▓▓▓▌
         ▄████▀    ▀████▄
         ▀▀▀▀        ▀▀▀▀
2015-03-10T08:27:58.5390490 info       [Vinelab'Minion'Client 5446] New client created
2015-03-10T08:27:58.5467130 info       [Thruway'Transport'PawlTransportProvider 5446] Starting Transport
2015-03-10T08:27:58.7215050 info       [Thruway'Transport'PawlTransportProvider 5446] Pawl has connected
2015-03-10T08:27:58.8066330 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [2,837176922,{"authrole":"anonymous","authmethod":"anonymous","roles":{"broker":{"features":{"publisher_identification":true,"publisher_exclusion":true,"pattern_based_subscription":true,"subscription_meta_api":true,"subscriber_blackwhite_listing":true}},"dealer":{"features":{"progressive_call_results":true,"pattern_based_registration":true,"registration_meta_api":true,"shared_registration":true,"caller_identification":true}}},"authid":"RK7RIery7evd71THp_Kzcx3h"}]
2015-03-10T08:27:58.8109340 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'WelcomeMessage]
2015-03-10T08:27:58.8110330 info       [Vinelab'Minion'Client 5446] We have been welcomed...
2015-03-10T08:27:58.8292430 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [65,1474724289953122,1308617500]
2015-03-10T08:27:58.8347220 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'RegisteredMessage]
2015-03-10T08:27:58.8350070 info       [Thruway'Role'Callee 5446] Setting registration_id for com.leadrm.app.message (0)
2015-03-10T08:27:58.8354950 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [33,2002512864967000,1374387471]
2015-03-10T08:27:58.8401330 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'SubscribedMessage]
2015-03-10T08:28:05.0705930 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [36,1374387471,1952879835,{},["test"]]
2015-03-10T08:28:05.0930590 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'EventMessage]
2015-03-10T08:36:11.6339470 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [36,1374387471,1879215773,{},["test"]]
2015-03-10T08:36:11.6341770 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'EventMessage]
2015-03-10T08:36:18.9851460 debug      [Thruway'Transport'PawlTransportProvider 5446] Received: [36,1374387471,851409442,{},["test"]]
2015-03-10T08:36:18.9854340 debug      [Vinelab'Minion'Client 5446] Client onMessage: [Thruway'Message'EventMessage]

$this->register不同于订阅。这是一个远程方法调用过程。

如果您需要订阅$this->subscribe('message','callbackfunction'),那么它将从thruway准备onMessage函数。

您可以将提供者设置为远程过程注册者,也可以订阅主题。session.call sendMessage当您需要发送消息时。