【问题标题】:Class 'PushManager' not found - Laravel 4.2找不到类“PushManager”-Laravel 4.2
【发布时间】:2015-08-17 12:25:36
【问题描述】:

我在 laravel 4.2 上,我正在尝试安装 https://github.com/Ph3nol/NotificationPusher

它安装得很好,但我遇到了错误:

Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Class 'PushManager' not found

当我如下运行 /push 路由时:

Route::get('push', function(){
    // First, instantiate the manager and declare an adapter.
    $pushManager    = new PushManager();
    $exampleAdapter = new ApnsAdapter();

    // Set the device(s) to push the notification to.
    $devices = new DeviceCollection(array(
        new Device('Token1'),
        new Device('Token2'),
        new Device('Token3'),
        // ...
    ));

    // Then, create the push skel.
    $message = new Message('This is an example.');

    // Finally, create and add the push to the manager, and push it!
    $push = new Push($exampleAdapter, $devices, $message);
    $pushManager->add($push);
    return $pushManager->push();
});

我会错过一步吗? (可能在我的 app.php 中声明提供者或别名)

【问题讨论】:

    标签: php laravel laravel-4 push-notification google-cloud-messaging


    【解决方案1】:

    在您的 routes.php 顶部添加以下内容:

    use Sly\NotificationPusher\PushManager;
    use Sly\NotificationPusher\Adapter\Apns as ApnsAdapter;
    

    路由在全局命名空间中定义,PushManager存储在另一个命名空间中,因此需要显式导入。

    【讨论】:

    • 好。然后我得到“找不到类'ApnsAdapter'”
    • 您还需要导入该类。但是我在最新版本的包中没有看到“ApnsAdapter”类。该类称为“Apns”。你是这个意思吗?
    • 是的。我从入门指南中复制了代码github.com/Ph3nol/NotificationPusher/blob/master/doc/…
    • 肯定有一些我在文档中看不到的步骤 - 定义提供程序?别名?设置我的 GCM 密钥?我唯一做的就是跑composer require sly/notification-pusher
    • 好的,我更新了答案,这就是他们在 ApnsAdaptere 自述文件中所做的
    猜你喜欢
    • 2015-12-29
    • 2015-06-18
    • 2019-06-02
    • 2016-07-12
    • 2015-10-01
    • 2016-01-28
    • 2016-08-23
    • 2016-10-25
    • 1970-01-01
    相关资源
    最近更新 更多