在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):pusher/pusher-http-laravel开源软件地址(OpenSource Url):https://github.com/pusher/pusher-http-laravel开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):DEPRECATEDLaravel now has built-in support for Pusher Channels. This is now the recommended approach to integrate Channels into a Laravel project. Currently, Pusher will continue to review any PRs and solve security vulnerabilities in this SDK, but will not be making any major improvements going forward. Pusher Channels Laravel LibraryA Pusher Channels bridge for Laravel. Formerly // Triggering events.
$pusher->trigger('my-channel', 'my_event', 'hello world');
// Authenticating Private channels.
$pusher->socket_auth('my-channel', 'socket_id');
// Want to use the facade?
Pusher::get('/channels'); InstallationRequire this package, with Composer, in the root directory of your project. $ composer require pusher/pusher-http-laravel Add the service provider to Pusher\Laravel\PusherServiceProvider::class If you want you can use the facade. Add the reference in 'Pusher' => Pusher\Laravel\Facades\Pusher::class ConfigurationThe Laravel Channels SDK requires connection configuration. To get started, you'll need to publish all vendor assets: $ php artisan vendor:publish --provider="Pusher\Laravel\PusherServiceProvider" This will create a Default Connection NameThis option Channels ConnectionsThis option Encrypted ChannelsTo enable end to end encrypted channels, you need to uncomment a line from the Channels config file
Then you need to set an UsagePusherManagerThis is the class of most interest. It is bound to the ioc container as Facades\PusherThis facade will dynamically pass static method calls to the PusherServiceProviderThis class contains no public methods of interest. This class should be added to the providers array in ExamplesHere you can see an example of just how simple this package is to use. Out of the box, the default adapter is // You can alias this in config/app.php.
use Pusher\Laravel\Facades\Pusher;
Pusher::trigger('my-channel', 'my-event', ['message' => $message]);
// We're done here - how easy was that, it just works!
Pusher::getSettings();
// This example is simple and there are far more methods available. The use Pusher\Laravel\Facades\Pusher;
// Writing this…
Pusher::connection('main')->log('They see me logging…');
// …is identical to writing this
Pusher::log('They hatin…');
// and is also identical to writing this.
Pusher::connection()->log('Tryin to catch me testing dirty…');
// This is because the main connection is configured to be the default.
Pusher::getDefaultConnection(); // This will return main.
// We can change the default connection.
Pusher::setDefaultConnection('alternative'); // The default is now alternative. If you prefer to use dependency injection over facades like me, then you can inject the manager: use Pusher\Laravel\PusherManager;
class Foo
{
protected $pusher;
public function __construct(PusherManager $pusher)
{
$this->pusher = $pusher;
}
public function bar()
{
$this->pusher->trigger('my-channel', 'my-event', ['message' => $message]);
}
}
App::make('Foo')->bar(); DocumentationThere are other classes in this package that are not documented here. This is because the package is a Laravel wrapper of the official Channels package. License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论