/**
  * Register the provider.
  *
  * @return void
  */
 public function register()
 {
     if (config('wechat.alias')) {
         Alias::register();
     }
     $this->app->singleton(['Overtrue\\Wechat\\Server' => 'wechat.server'], function ($app) {
         return new WechatServer(config('wechat.app_id'), config('wechat.token'), config('wechat.encoding_key'));
     });
     foreach ($this->services as $alias => $service) {
         $this->app->singleton([$service => $alias], function ($app) use($service) {
             return new $service(config('wechat.app_id'), config('wechat.secret'));
         });
     }
 }
Exemple #2
0
 /**
  * Register the provider.
  *
  * @return void
  */
 public function register()
 {
     if (config('wechat.alias')) {
         Alias::register();
     }
     if (config('wechat') == (include __DIR__ . '/config.php')) {
         throw new \Exception("请先在config/wechat.php完成微信相关配置");
     }
     $this->app->singleton(['Overtrue\\Wechat\\Server' => 'wechat.server'], function ($app) {
         return new WechatServer(config('wechat.app_id'), config('wechat.token'), config('wechat.encoding_key'));
     });
     foreach ($this->services as $alias => $service) {
         $this->app->singleton([$service => $alias], function ($app) use($service) {
             return new $service(config('wechat.app_id'), config('wechat.secret'));
         });
     }
 }