Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Dyz598/feat/broadcasting
feat(broadcasting): added broadcasting bundle
- Loading branch information
Showing
3 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pandawa\Bundle\BroadcastingBundle; | ||
|
||
use Illuminate\Broadcasting\BroadcastManager; | ||
use Illuminate\Broadcasting\BroadcastServiceProvider; | ||
use Illuminate\Contracts\Broadcasting\Broadcaster as BroadcasterContract; | ||
use Illuminate\Contracts\Broadcasting\Factory as BroadcastingFactory; | ||
use Illuminate\Contracts\Support\DeferrableProvider; | ||
use Pandawa\Bundle\FoundationBundle\Plugin\ImportConfigurationPlugin; | ||
use Pandawa\Bundle\FoundationBundle\Plugin\RegisterBundlesPlugin; | ||
use Pandawa\Component\Foundation\Bundle\Bundle; | ||
use Pandawa\Contracts\Foundation\HasPluginInterface; | ||
|
||
/** | ||
* @author Aldi Arief <aldiarief598@gmail.com> | ||
*/ | ||
class BroadcastingBundle extends Bundle implements HasPluginInterface, DeferrableProvider | ||
{ | ||
protected array $deferred = [ | ||
BroadcastManager::class, | ||
BroadcastingFactory::class, | ||
BroadcasterContract::class, | ||
]; | ||
|
||
public function configure(): void | ||
{ | ||
$this->app->singleton(BroadcastManager::class, function ($app) { | ||
return new BroadcastManager($app); | ||
}); | ||
|
||
$this->app->singleton(BroadcasterContract::class, function ($app) { | ||
return $app->make(BroadcastManager::class)->connection(); | ||
}); | ||
|
||
$this->app->alias( | ||
BroadcastManager::class, BroadcastingFactory::class | ||
); | ||
} | ||
|
||
public function plugins(): array | ||
{ | ||
return [ | ||
new ImportConfigurationPlugin(), | ||
new RegisterBundlesPlugin([ | ||
BroadcastServiceProvider::class, | ||
]), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default Broadcaster | ||
|-------------------------------------------------------------------------- | ||
| | ||
| This option controls the default broadcaster that will be used by the | ||
| framework when an event needs to be broadcast. You may set this to | ||
| any of the connections defined in the "connections" array below. | ||
| | ||
| Supported: "pusher", "ably", "redis", "log", "null" | ||
| | ||
*/ | ||
|
||
'default' => env('BROADCAST_DRIVER', 'null'), | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Broadcast Connections | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Here you may define all of the broadcast connections that will be used | ||
| to broadcast events to other systems or over websockets. Samples of | ||
| each available type of connection are provided inside this array. | ||
| | ||
*/ | ||
|
||
'connections' => [ | ||
|
||
'pusher' => [ | ||
'driver' => 'pusher', | ||
'key' => env('PUSHER_APP_KEY'), | ||
'secret' => env('PUSHER_APP_SECRET'), | ||
'app_id' => env('PUSHER_APP_ID'), | ||
'options' => [ | ||
'cluster' => env('PUSHER_APP_CLUSTER'), | ||
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com', | ||
'port' => env('PUSHER_PORT', 443), | ||
'scheme' => env('PUSHER_SCHEME', 'https'), | ||
'encrypted' => true, | ||
'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', | ||
], | ||
'client_options' => [ | ||
// Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html | ||
], | ||
], | ||
|
||
'ably' => [ | ||
'driver' => 'ably', | ||
'key' => env('ABLY_KEY'), | ||
], | ||
|
||
'redis' => [ | ||
'driver' => 'redis', | ||
'connection' => 'default', | ||
], | ||
|
||
'log' => [ | ||
'driver' => 'log', | ||
], | ||
|
||
'null' => [ | ||
'driver' => 'null', | ||
], | ||
|
||
], | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "pandawa/broadcasting-bundle", | ||
"description": "The pandawa broadcasting bundle", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Iqbal Maulana", | ||
"email": "iq.bluejack@gmail.com" | ||
}, | ||
{ | ||
"name": "Aldi Arief", | ||
"email": "aldiarief598@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=8.1", | ||
"pandawa/dependency-injection-bundle": "^5.0", | ||
"pandawa/foundation-bundle": "^5.0", | ||
"illuminate/broadcasting": "^9.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Pandawa\\Bundle\\BroadcastingBundle\\": "" | ||
} | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "5.x-dev" | ||
}, | ||
"laravel": { | ||
"providers": [ | ||
"Pandawa\\Bundle\\BroadcastingBundle\\BroadcastingBundle" | ||
] | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"minimum-stability": "dev" | ||
} |