Class 'Sly\NotificationPusher\Adapter\' not found when switched to Laravel Envoyer
background
I used to use Laravel forge for setting up my server and for deployment.
Also, I often use laravel tinker to execute quick commands, both on my localhost and on the staging/prod servers
problem
As we started horizontally scaling, I switched to envoyer. Apparently envoyer simply gets the latest commit on git (master branch or whatever branch you specify), makes a tarball out of it and dumps it into a folder every release, then symlink to it (see more details in this laracast).
Which is all fine, but ever since we switched to envoyer my push notification smoke test on tinker broke:
$job = new Jobs\PushNotificationsJob([387], ['action' => 'order_canceled',
'alert' => 'Hello World']);
$job->handle();
this used to work fine (and still does on localhost), but now on the staging/prod where envoyer deploys, I get this error:
PHP Error: Class 'Sly\NotificationPusher\Adapter' not found in /home/forge/default/vendor/davibennun/laravel-push-notification/src/Davibennun/LaravelPushNotification/App.php on line 19
what I have tried
I simply ran composer install on prod, didn't work. After that I compared my composer.lock between localhost and prod, and they're exactly the same:
{
"name": "sly/notification-pusher",
"version": "v2.3.0",
"source": {
"type": "git",
"url": "https://github.com/Ph3nol/NotificationPusher.git",
"reference": "c56005a3b9168324713743edcc7da7ada4aad2a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ph3nol/NotificationPusher/zipball/c56005a3b9168324713743edcc7da7ada4aad2a2",
"reference": "c56005a3b9168324713743edcc7da7ada4aad2a2",
"shasum": ""
},
"require": {
"doctrine/inflector": "~1.0",
"php": ">=5.6",
"symfony/console": "~2.3|~3.0",
"symfony/filesystem": "^3.3",
"symfony/options-resolver": "~2.3|~3.0",
"symfony/process": "~2.3|~3.0",
"zendframework/zendservice-apple-apns": "1.*",
"zendframework/zendservice-google-gcm": "2.*"
},
"require-dev": {
"atoum/atoum": "^3.1",
"atoum/stubs": "^2.5",
"symfony/var-dumper": "^3.3"
},
"bin": [
"np"
],
"type": "standalone",
"autoload": {
"psr-0": {
"Sly": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Cédric Dugat",
"email": "[email protected]"
},
{
"name": "Contributors",
"homepage": "https://github.com/Ph3nol/NotificationPusher/contributors"
}
],
"description": "Standalone PHP library for easy devices notifications push.",
"homepage": "https://github.com/Ph3nol/NotificationPusher",
"keywords": [
"android",
"apns",
"apple",
"gcm",
"iphone",
"message",
"notification",
"push",
"pusher"
],
"time": "2017-08-10 10:40:41"
}
However, I found it strange that the sly files on prod are slightly different from the ones on localhost, for example If I compare the output of this command on both envss
command:
find . | grep NotificationPusher | grep -v tests | grep Adapter
localhost:
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/AdapterInterface.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Apns.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/BaseAdapter.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Gcm.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Exception/AdapterException.php
prod:
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Exception/AdapterException.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/AdapterInterface.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/BaseAdapter.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/FeedbackAdapterInterface.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Gcm.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/Apns.php
./vendor/sly/notification-pusher/src/Sly/NotificationPusher/Adapter/ApnsAPI.php
so you'll notice prod seems a bit newer, since it has files like ApnsAPI.php which localhost doesn't. But I'm not sure if any of this is relevant.
the offending line is here
public function __construct($config)
{
$this->pushManager = new PushManager($config['environment'] == "development" ? PushManager::ENVIRONMENT_DEV : PushManager::ENVIRONMENT_PROD);
$adapterClassName = 'Sly\NotificationPusher\Adapter\'.ucfirst($config['service']);
$adapterConfig = $config;
unset($adapterConfig['environment'], $adapterConfig['service']);
$this->adapter = new $adapterClassName($adapterConfig); <-----
}
but i'm not sure what else to do.. ideas?
Please or to participate in this conversation.