Timothy
Timothy

Reputation: 4285

Class 'PushManager' not found - Laravel 4.2

I am on laravel 4.2 and im trying to install https://github.com/Ph3nol/NotificationPusher

It installed well but I ran into the error:

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

when I ran the /push route as below:

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();
});

Could I be missing a step? (perhaps declaring a provider or alias in my app.php)

Upvotes: 1

Views: 613

Answers (1)

jedrzej.kurylo
jedrzej.kurylo

Reputation: 40919

Add the following at the top of your routes.php:

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

Routes are being defined in global namespace, PushManager is stored in another namespace, so it needs to be explicitly imported.

Upvotes: 1

Related Questions