├── LICENSE ├── composer.json ├── config └── pusher.php └── src ├── Facades └── Pusher.php ├── PusherFactory.php ├── PusherManager.php └── PusherServiceProvider.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Pusher, Ltd (https://pusher.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pusher/pusher-http-laravel", 3 | "description": "[DEPRECATED] A Pusher bridge for Laravel", 4 | "license": "MIT", 5 | "keywords": ["laravel", "pusher", "http", "api", "php-pusher-server", "rest", "realtime", "trigger", "publish", "events"], 6 | "authors": [ 7 | { 8 | "name": "Vincent Klaiber", 9 | "email": "hello@vinkla.com", 10 | "homepage": "https://vinkla.com" 11 | } 12 | ], 13 | "require": { 14 | "php": "^7.0", 15 | "illuminate/contracts": "^5.5|^6.0|^7.0", 16 | "illuminate/support": "^5.5|^6.0|^7.0", 17 | "graham-campbell/manager": "^3.0|^4.0", 18 | "pusher/pusher-php-server": "^3.3|^4.0" 19 | }, 20 | "require-dev": { 21 | "graham-campbell/analyzer": "^2.4", 22 | "graham-campbell/testbench": "^4.0|^5.0", 23 | "mockery/mockery": "^1.0", 24 | "phpunit/phpunit": "^6.5|^7.0|^8.0" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "Pusher\\Laravel\\": "src/" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "Pusher\\Tests\\Laravel\\": "tests/" 34 | } 35 | }, 36 | "config": { 37 | "preferred-install": "dist" 38 | }, 39 | "extra": { 40 | "branch-alias": { 41 | "dev-master": "4.2-dev" 42 | }, 43 | "laravel": { 44 | "providers": [ 45 | "Pusher\\Laravel\\PusherServiceProvider" 46 | ], 47 | "aliases": { 48 | "Pusher": "Pusher\\Laravel\\Facades\\Pusher" 49 | } 50 | } 51 | }, 52 | "minimum-stability": "dev", 53 | "prefer-stable": true 54 | } 55 | -------------------------------------------------------------------------------- /config/pusher.php: -------------------------------------------------------------------------------- 1 | 'main', 28 | 29 | /* 30 | |-------------------------------------------------------------------------- 31 | | Pusher Connections 32 | |-------------------------------------------------------------------------- 33 | | 34 | | Here are each of the connections setup for your application. Example 35 | | configuration has been included, but you may add as many connections as 36 | | you would like. 37 | | 38 | */ 39 | 40 | 'connections' => [ 41 | 42 | 'main' => [ 43 | 'auth_key' => env('PUSHER_APP_KEY'), 44 | 'secret' => env('PUSHER_APP_SECRET'), 45 | 'app_id' => env('PUSHER_APP_ID'), 46 | 'options' => [ 47 | 'cluster' => env('PUSHER_APP_CLUSTER'), 48 | // 'encryption_master_key' => env('PUSHER_ENCRYPTION_MASTER_KEY'), 49 | ], 50 | 'host' => null, 51 | 'port' => null, 52 | 'timeout' => null, 53 | ], 54 | 55 | 'alternative' => [ 56 | 'auth_key' => 'your-auth-key', 57 | 'secret' => 'your-secret', 58 | 'app_id' => 'your-app-id', 59 | 'options' => [], 60 | 'host' => null, 61 | 'port' => null, 62 | 'timeout' => null, 63 | ], 64 | 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /src/Facades/Pusher.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Pusher extends Facade 24 | { 25 | /** 26 | * Get the registered name of the component. 27 | * 28 | * @return string 29 | */ 30 | protected static function getFacadeAccessor(): string 31 | { 32 | return 'pusher'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/PusherFactory.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class PusherFactory 26 | { 27 | /** 28 | * Make a new Pusher client. 29 | * 30 | * @param array $config 31 | * 32 | * @return \Pusher\Pusher 33 | */ 34 | public function make(array $config): Pusher 35 | { 36 | $config = $this->getConfig($config); 37 | 38 | return $this->getClient($config); 39 | } 40 | 41 | /** 42 | * Get the configuration data. 43 | * 44 | * @param string[] $config 45 | * 46 | * @throws \InvalidArgumentException 47 | * 48 | * @return array 49 | */ 50 | protected function getConfig(array $config): array 51 | { 52 | $keys = [ 53 | 'auth_key', 54 | 'secret', 55 | 'app_id', 56 | 'options', 57 | 'host', 58 | 'port', 59 | 'timeout', 60 | ]; 61 | 62 | foreach ($keys as $key) { 63 | if (!array_key_exists($key, $config)) { 64 | throw new InvalidArgumentException("Missing configuration key [$key]."); 65 | } 66 | } 67 | 68 | foreach ($config['options'] as $option => $value) { 69 | if (is_null($value)) { 70 | unset($config['options'][$option]); 71 | } 72 | } 73 | 74 | return Arr::only($config, $keys); 75 | } 76 | 77 | /** 78 | * Get the pusher client. 79 | * 80 | * @param string[] $auth 81 | * 82 | * @return \Pusher\Pusher 83 | */ 84 | protected function getClient(array $auth): Pusher 85 | { 86 | return new Pusher( 87 | $auth['auth_key'], 88 | $auth['secret'], 89 | $auth['app_id'], 90 | $auth['options'], 91 | $auth['host'], 92 | $auth['port'], 93 | $auth['timeout'] 94 | ); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/PusherManager.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class PusherManager extends AbstractManager 26 | { 27 | /** 28 | * The factory instance. 29 | * 30 | * @var \Pusher\Laravel\PusherFactory 31 | */ 32 | private $factory; 33 | 34 | /** 35 | * Create a new Pusher manager instance. 36 | * 37 | * @param \Illuminate\Contracts\Config\Repository $config 38 | * @param \Pusher\Laravel\PusherFactory $factory 39 | * 40 | * @return void 41 | */ 42 | public function __construct(Repository $config, PusherFactory $factory) 43 | { 44 | parent::__construct($config); 45 | 46 | $this->factory = $factory; 47 | } 48 | 49 | /** 50 | * Create the connection instance. 51 | * 52 | * @param array $config 53 | * 54 | * @return \Pusher\Pusher 55 | */ 56 | protected function createConnection(array $config): Pusher 57 | { 58 | return $this->factory->make($config); 59 | } 60 | 61 | /** 62 | * Get the configuration name. 63 | * 64 | * @return string 65 | */ 66 | protected function getConfigName(): string 67 | { 68 | return 'pusher'; 69 | } 70 | 71 | /** 72 | * Get the factory instance. 73 | * 74 | * @return \Pusher\Laravel\PusherFactory 75 | */ 76 | public function getFactory(): PusherFactory 77 | { 78 | return $this->factory; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/PusherServiceProvider.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | class PusherServiceProvider extends ServiceProvider 28 | { 29 | /** 30 | * Boot the service provider. 31 | * 32 | * @return void 33 | */ 34 | public function boot() 35 | { 36 | $this->setupConfig(); 37 | } 38 | 39 | /** 40 | * Setup the config. 41 | * 42 | * @return void 43 | */ 44 | protected function setupConfig() 45 | { 46 | $source = realpath(__DIR__.'/../config/pusher.php'); 47 | 48 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { 49 | $this->publishes([$source => config_path('pusher.php')]); 50 | } elseif ($this->app instanceof LumenApplication) { 51 | $this->app->configure('pusher'); 52 | } 53 | 54 | $this->mergeConfigFrom($source, 'pusher'); 55 | } 56 | 57 | /** 58 | * Register the service provider. 59 | * 60 | * @return void 61 | */ 62 | public function register() 63 | { 64 | $this->registerFactory(); 65 | $this->registerManager(); 66 | $this->registerBindings(); 67 | } 68 | 69 | /** 70 | * Register the factory class. 71 | * 72 | * @return void 73 | */ 74 | protected function registerFactory() 75 | { 76 | $this->app->singleton('pusher.factory', function () { 77 | return new PusherFactory(); 78 | }); 79 | 80 | $this->app->alias('pusher.factory', PusherFactory::class); 81 | } 82 | 83 | /** 84 | * Register the manager class. 85 | * 86 | * @return void 87 | */ 88 | protected function registerManager() 89 | { 90 | $this->app->singleton('pusher', function (Container $app) { 91 | $config = $app['config']; 92 | $factory = $app['pusher.factory']; 93 | 94 | return new PusherManager($config, $factory); 95 | }); 96 | 97 | $this->app->alias('pusher', PusherManager::class); 98 | } 99 | 100 | /** 101 | * Register the bindings. 102 | * 103 | * @return void 104 | */ 105 | protected function registerBindings() 106 | { 107 | $this->app->bind('pusher.connection', function (Container $app) { 108 | $manager = $app['pusher']; 109 | 110 | return $manager->connection(); 111 | }); 112 | 113 | $this->app->alias('pusher.connection', Pusher::class); 114 | } 115 | 116 | /** 117 | * Get the services provided by the provider. 118 | * 119 | * @return string[] 120 | */ 121 | public function provides(): array 122 | { 123 | return [ 124 | 'pusher', 125 | 'pusher.factory', 126 | 'pusher.connection', 127 | ]; 128 | } 129 | } 130 | --------------------------------------------------------------------------------