Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

crashing after fresh install #43

Closed
joaosauer opened this issue Apr 18, 2017 · 9 comments
Closed

crashing after fresh install #43

joaosauer opened this issue Apr 18, 2017 · 9 comments

Comments

@joaosauer
Copy link

joaosauer commented Apr 18, 2017

Hi,

I had followed the step by step explanation, but I'm getting an error when trying to send a message.

ErrorException in Manager.php line 77:
Missing argument 1 for Illuminate\Support\Manager::createDriver(), called in D:\vendor\laravel\framework\src\Illuminate\Support\Manager.php on line 88 and defined
in Manager.php line 77
at HandleExceptions->handleError(2, 'Missing argument 1 for Illuminate\\Support\\Manager::createDriver(), called in D:\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Manager.php on line 88 and defined', 'D:\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Manager.php', 77, array('this' => object(FCMManager))) in Manager.php line 77
at Manager->createDriver() in Manager.php line 88
at Manager->createDriver(null) in Manager.php line 63
at Manager->driver() in FCMServiceProvider.php line 27
at FCMServiceProvider->LaravelFCM\{closure}(object(Application), array()) in Container.php line 716
at Container->build(object(Closure)) in Container.php line 598
at Container->resolve('fcm.client') in Container.php line 567
at Container->make('fcm.client') in Application.php line 708
at Application->make('fcm.client') in Container.php line 1139
at Container->offsetGet('fcm.client') in FCMServiceProvider.php line 38
at FCMServiceProvider->LaravelFCM\{closure}(object(Application), array()) in Container.php line 716
at Container->build(object(Closure)) in Container.php line 598
at Container->resolve('fcm.sender') in Container.php line 567
at Container->make('fcm.sender') in Application.php line 708
at Application->make('fcm.sender') in Container.php line 1139
at Container->offsetGet('fcm.sender') in Facade.php line 159
at Facade::resolveFacadeInstance('fcm.sender') in Facade.php line 128
at Facade::getFacadeRoot() in Facade.php line 215
at Facade::__callStatic('sendTo', array(array('dFQwbIxI3J0:APA91bFzXpm4atxUHhtAYvZLfZsx78kCI711'), object(Options), object(PayloadNotification), object(PayloadData))) in ApiController.php line 190
at FCM::sendTo(array('dFQwbIxI3J0:Ch6HGrkAqe6p0ra969kjBa_HzdqAsgfi67EMbLI711'), object(Options), object(PayloadNotification), object(PayloadData)) in ApiController.php line 190
at ApiController::sendMessageToToken(object(Collection), 'Testing') in ApiController.php line 166
at ApiController->alertTeacherForDelay('15')
at call_user_func_array(array(object(ApiController), 'alertTeacherForDelay'), array('min' => '15')) in Controller.php line 55
at Controller->callAction('alertTeacherForDelay', array('min' => '15')) in ControllerDispatcher.php line 44
at ControllerDispatcher->dispatch(object(Route), object(ApiController), 'alertTeacherForDelay') in Route.php line 204
at Route->runController() in Route.php line 160

Any idea what I'm doing wrong? Or is this a real bug?

PS: I already cleaned the cache in all the possible ways that I found in the internet and still no luck.

Thanks,
Joao

@brozot
Copy link
Owner

brozot commented Apr 19, 2017

Hello have you done an artisan publish command ?

@joaosauer
Copy link
Author

Hi,

Yep, I had made the "php artisan vendor:publish".
To be honest, I rechecked twice all the commands that were wrote in the readme.md
I even tried to understand the problem, that appears to be because the variable $app is undefined. But I cannot understand from where this is coming from.
sorry, I'm new to laravel, but I already installed few packages and didn't have this issue before.
Can I check any file to verify if I installed it correctly?

Thanks,
Joao

@brozot
Copy link
Owner

brozot commented Apr 19, 2017

It could be that you haven't done the php artisan vendor:publish before the registration of the serviceprovider (LaravelFCM\FCMServiceProvider::class ) in the app.php file.

please try again php artisan vendor:publish with LaravelFCM\FCMServiceProvider::classregistered in your config/app-php file.

Please give me a feedback if it's working or not

PS: Please check if in config folder you have a fcm.php file.

Best regards

@joaosauer
Copy link
Author

joaosauer commented Apr 19, 2017

Sorry, but didn't work (Same error):
here is the result of the vendor:publish command:

D:\>php artisan vendor:publish
Copied Directory [\vendor\laravel\framework\src\Illuminate\Notifications\resources\views] To [\resources\views\vendor\notifications]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Pagination\resources\views] To [\resources\views\vendor\pagination]
Copied Directory [\vendor\laravel\passport\resources\views] To [\resources\views\vendor\passport]
Copied Directory [\vendor\laravel\passport\resources\assets\js\components] To [\resources\assets\js\components\passport]
Copied Directory [\vendor\laravel\framework\src\Illuminate\Mail\resources\views] To [\resources\views\vendor\mail]
Publishing complete.

I can also confirm that the fcm.php file is in the config folder(I added the SERVER_KEY and SENDER_ID in the .env file):

return [
    'driver' => env('FCM_PROTOCOL', 'http'),
    'log_enabled' => true,

    'http' => [
        'server_key' => env('FCM_SERVER_KEY', 'Your FCM server key'),
        'sender_id' => env('FCM_SENDER_ID', 'Your sender id'),
        'server_send_url' => 'https://fcm.googleapis.com/fcm/send',
        'server_group_url' => 'https://android.googleapis.com/gcm/notification',
        'timeout' => 30.0, // in second
    ],
];

I did add the serviceprovider in the app.php file (Before calling the vendor:publish):

....
        /*
         * Package Service Providers...
         */
        Laravel\Tinker\TinkerServiceProvider::class,
        Laravel\Passport\PassportServiceProvider::class,

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        // App\Providers\BroadcastServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

        LaravelFCM\FCMServiceProvider::class,
    ],

and also:

....
        'URL' => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View' => Illuminate\Support\Facades\View::class,
        'FCM'      => LaravelFCM\Facades\FCM::class,
        'FCMGroup' => LaravelFCM\Facades\FCMGroup::class, // Optional
    ],

Finally, the ONLY thing that I thought that was weird is that my bootstrap\app.php file doesn't contain anything similar of what the LUMEN part was saying. I actually never opened this file before. But I still added the lines to this file. Then, I did notice that the aliases didn't work in my code, but I just added the full path to get it running (Still crashing, but not complaining that the FCM was not found).
My bootstrap\app.php

<?php

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

/*
|--------------------------------------------------------------------------
| Bind Important Interfaces
|--------------------------------------------------------------------------
|
| Next, we need to bind some important interfaces into the container so
| we will be able to resolve them when needed. The kernels serve the
| incoming requests to this application from both the web and CLI.
|
*/

$app->singleton(
    Illuminate\Contracts\Http\Kernel::class,
    App\Http\Kernel::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->register(LaravelFCM\FCMServiceProvider::class);

class_alias(\LaravelFCM\Facades\FCM::class, 'FCM');
class_alias(\LaravelFCM\Facades\FCMGroup::class, 'FCMGroup');

/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/

return $app;

And, in my file, I'm using:

use LaravelFCM\Facades\FCM;
use LaravelFCM\Message\OptionsBuilder;
use LaravelFCM\Message\PayloadDataBuilder;
use LaravelFCM\Message\PayloadNotificationBuilder;

and this is the entire method:

public static function sendMessageToToken($users, $message) {
        $tokens = [];
        foreach ($users as $user) {
            foreach ($user->fcmTokens as $token)
                $tokens[] = $token;
        }
        $tokens[] = "dFQwbIxI3J0:APA91bFzXpm4atxAYvZLfZsx78kCI711";

        $optionBuiler = new OptionsBuilder();
        $optionBuiler->setTimeToLive(60*20);

        $notificationBuilder = new PayloadNotificationBuilder('AgendaF1');
        $notificationBuilder->setBody($message)->setSound('default');

        $dataBuilder = new PayloadDataBuilder();
        $dataBuilder->addData(['a_data' => 'my_data']);   

        $option = $optionBuiler->build();
        $notification = $notificationBuilder->build();
        $data = $dataBuilder->build();

        $downstreamResponse = FCM::sendTo($tokens, $option, $notification, $data);

        return $downstreamResponse->numberSuccess();

//        $downstreamResponse->numberFailure();
//        $downstreamResponse->numberModification();
//
////return Array - you must remove all this tokens in your database
//        $downstreamResponse->tokensToDelete();
//
////return Array (key : oldToken, value : new token - you must change the token in your database )
//        $downstreamResponse->tokensToModify();
    }

I believe that this is all the files that I changed. Any idea what is wrong? How can I force a republish, just to be sure?

@brozot
Copy link
Owner

brozot commented Apr 19, 2017

It's strange. It's look like a issue with the config file.

Can you try to remove all files and the package in vendor/brozot/then reinstall it with composer, remove also the config/fcm.php

make a vendor:publish command.

you can also remove the content added in your boostrap/app.phpyou need to add this line only if you use Lumen.

Thank you

@joaosauer
Copy link
Author

Just tried what you said.
Got the same error.
Could be related to the laravel version? I'm using the: Laravel Framework 5.4.19

@brozot
Copy link
Owner

brozot commented Apr 20, 2017

I have tried also with Laravel 5.4.19 and it works for me.

I have release a new version 1.2.4.

In this version the command vendor:publish is optional.

Can you try to update the package

thank you

@joaosauer
Copy link
Author

Hey,

Thanks for the changes, apparently this fixed the initial issue.
Now I'm getting a new one:

RequestException in CurlFactory.php line 187:
cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
in CurlFactory.php line 187
at CurlFactory::createRejection(object(EasyHandle), array('errno' => 60, 'error' => 'SSL certificate problem: unable to get local issuer certificate', 'url' => 'https://fcm.googleapis.com/fcm/send', 'content_type' => null, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 20, 'redirect_count' => 0, 'total_time' => 0.188, 'namelookup_time' => 0.063, 'connect_time' => 0.078, 'pretransfer_time' => 0, 'size_upload' => 0, 'size_download' => 0, 'speed_download' => 0, 'speed_upload' => 0, 'download_content_length' => -1, 'upload_content_length' => -1, 'starttransfer_time' => 0, 'redirect_time' => 0, 'redirect_url' => '', 'primary_ip' => '216.58.202.10', 'certinfo' => array(), 'primary_port' => 443, 'local_ip' => '192.168.25.8', 'local_port' => 58176)) in CurlFactory.php line 150
at CurlFactory::finishError(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlFactory.php line 103
at CurlFactory::finish(object(CurlHandler), object(EasyHandle), object(CurlFactory)) in CurlHandler.php line 43
at CurlHandler->__invoke(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 28
at Proxy::GuzzleHttp\Handler\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Proxy.php line 51
at Proxy::GuzzleHttp\Handler\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in PrepareBodyMiddleware.php line 72
at PrepareBodyMiddleware->__invoke(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false)) in Middleware.php line 30
at Middleware::GuzzleHttp\{closure}(object(Request), array('synchronous' => true, 'timeout' => 30, 'handler' => object(HandlerStack), 'allow_redirects' => array('max' => 5, 'protocols' => array('http', 'https'), 'strict' => false, 'referer' => false, 'track_redirects' => false), 'http_errors' =>

I will investigate this error as well. If I found something I will let you know.

@joaosauer
Copy link
Author

Hey,

Great news!!!! It worked!
I found the solution for the last problem here(I'm using a localhost php and mysql installations):
link here
I will copy here the solution (It was not me that wrote it, it's the person in the link above):


Go to http://curl.haxx.se/ca/cacert.pem and download the pem file and save in your php installation directory ( make sure while saving it retains the extension and not saved as a text file )

Now, open your php.ini file, scroll to the bottom and add the following line:

[cURL]
curl.cainfo="D:\xampp\php\cacert.pem"
Replace D:\xampp\php\cacert.pem with the actual path.

Courtesy: http://stackoverflow.com/questions/17478283/paypal-access-ssl-certificate-unable-to-get-local-issuer-certificate

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants