wensleydale / sendpulse-laravel
用于在Laravel 5中设置和使用SendPulse PHP库的最小服务提供者
v1.0.1
2016-01-19 22:00 UTC
Requires
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-09-14 18:58:34 UTC
README
这是一个服务提供者和外观,用于在Laravel 5中设置和使用SendPulse PHP库。
此包包含一个服务提供者,它将初始化的SendPulse客户端实例绑定到IoC容器,并提供一个SendPulse外观,以便您可以通过以下语法访问SendpulseApi类的所有方法:
$message = ['title' => 'My first notification', 'website_id' => 1, 'body' => 'I am the body of the push message']; SendPulse::createPushTask($message);
您应该参考SendPulse API和底层的SendPush PHP类以获取所有可用方法的详细信息。
设置
-
安装'wensleydale/sendpulse-laravel'包
注意,这将同时安装所需的wensleydale/sendpulse-rest-api-php包。
$ composer require wensleydale/sendpulse-laravel:1.*
-
更新'config/app.php'
# Add `SendPulseLaravelServiceProvider` to the `providers` array 'providers' => array( ... 'SendPulse\SendPulseLaravel\SendPulseLaravelServiceProvider', ) # Add the `SendPushFacade` to the `aliases` array 'aliases' => array( ... 'SendPulse' => 'SendPulse\SendPulseLaravel\SendPulseFacade', )
-
发布配置文件(在config目录中创建sendpulse.php)并添加您的API密钥和可选的默认设置。
$ php artisan vendor:publish
类型提示
如果您不想使用SendPulse外观,您可以在由IoC容器解析的类的构造函数中“类型提示”SendPulse依赖项,并准备就绪的实例即可使用。
use SendPulse\SendpulseApi; private $client; public function __construct(SendpulseApi $client) { $this->client = $client; } public function getWebsites() { $this->client->pushListWebsites(); }