简体   繁体   中英

class 'Pusher\Pusher' not found required in laravel package

I'm creating my own Laravel package and I required Pusher server in my package, in my composer.json there is a pusher required and I also checked it in vendor folder also exist... and when I'm trying to use it in my package controller like use Pusher\Pusher ; it says that class 'Pusher\Pusher' not found!!!

my composer.json:

...
"require": {
    ...
    "pusher/pusher-php-server": "^3.4@dev"
},
...

in my controller I added use Pusher\Pusher; and the use is like that:

public function pusher()
{
    $pusher = new Pusher(
        env('PUSHER_APP_KEY'),
        env('PUSHER_APP_SECRET'),
        env('PUSHER_APP_ID'),
        [
            'cluster' => env('PUSHER_APP_CLUSTER'),
            'encrypted' => true
        ]
    );
}

Does anyone have a solution?? Thanks in advance.

I got nothing after a long ride of searching in google and asking the developer...

But I finally SOLVED it:)

If you are developing your own package and trying to require a dependency inside the package.. and got the same error., all you need to do is to require it at the beginning of creating the composer.json file for your package. or put your dependencies in the require of your composer.json file and remove your package from laravel app and then re-install it.

you may not need to do that, all you need is to require the dependency and everything gonna work successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM