Php 类别';PushManager';未找到-Laravel 4.2
我在Laravel4.2上,我正在尝试安装 它安装得很好,但我遇到了错误:Php 类别';PushManager';未找到-Laravel 4.2,php,laravel,laravel-4,push-notification,google-cloud-messaging,Php,Laravel,Laravel 4,Push Notification,Google Cloud Messaging,我在Laravel4.2上,我正在尝试安装 它安装得很好,但我遇到了错误: Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN) Class 'PushManager' not found 当我运行/推送路线时,如下所示: Route::get('push', function(){ // First, instantiate the manager and declare an adapte
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Class 'PushManager' not found
当我运行/推送路线时,如下所示:
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();
});
我会错过一步吗?(可能在my app.php中声明提供者或别名)在您的路由的顶部添加以下内容:
use Sly\NotificationPusher\PushManager;
use Sly\NotificationPusher\Adapter\Apns as ApnsAdapter;
路由是在全局命名空间中定义的,PushManager存储在另一个命名空间中,因此需要显式导入它。很好。然后我得到“Class'ApnsAdapter'notfound”,您也需要导入该类。但是我在最新版本的包中没有看到“ApnsAdapter”类。该类称为“Apns”。这就是你的意思吗?是的。我复制了《入门指南》中的代码,在文档定义提供程序中肯定有一些步骤我看不到?别名?设置我的GCM密钥?我所做的唯一一件事就是运行
composer require sly/notification pusher
Ok,我更新了答案,这就是他们在ApnsAdaptere自述中所做的