/** * 初始化 */ public function init() { if (empty($this->agentsConfig) || empty($this->agentsName)) { throw Exception('$agentsConfig and agentsName is required'); } Sms::enable($this->agentsName); Sms::agents($this->agentsConfig); }
public function testAddAgentConfig() { Sms::agents('Log', []); $this->assertCount(1, Sms::getAgentsConfig()); Sms::agents('Luosimao', ['apikey' => '123']); $this->assertCount(2, Sms::getAgentsConfig()); Sms::agents(['Luosimao' => ['apikey' => '123'], 'YunPian' => ['apikey' => '123']]); $this->assertCount(3, Sms::getAgentsConfig()); }
/** * Register the service provider. * * @return void */ public function register() { $this->package('hardywen/phpsms-l4', null, realpath(__DIR__ . '/../src/')); $this->app->singleton('phpsms-l4', function ($app) { $config = $app->config->get('phpsms-l4::config'); Sms::enable(isset($config['enable']) ? $config['enable'] : []); Sms::agents(isset($config['agents']) ? $config['agents'] : []); return new Sms(false); }); }
/** * register service provider */ public function register() { //merge configs $this->mergeConfigFrom(__DIR__ . '/../config/phpsms.php', 'phpsms'); Sms::enable(config('phpsms.enable', [])); Sms::agents(config('phpsms.agents', [])); $this->app->singleton('PhpSms', function ($app) { return new Sms(); }); }