我正在使用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中声明提供者或别名)
答案 0 :(得分:1)
在 routes.php :
的顶部添加以下内容use Sly\NotificationPusher\PushManager;
use Sly\NotificationPusher\Adapter\Apns as ApnsAdapter;
路由正在全局命名空间中定义, PushManager 存储在另一个命名空间中,因此需要显式导入。