diff --git a/src/Facade.php b/src/Facade.php deleted file mode 100644 index a0167ea..0000000 --- a/src/Facade.php +++ /dev/null @@ -1,40 +0,0 @@ - 'Overtrue\\Wechat\\Image', ]; + /** * Boot the provider. * @@ -53,26 +60,28 @@ public function register() Alias::register(); } - $this->app->singleton('wechat.server', function($app){ - return new WechatServer(config('wechat.appId'), config('wechat.token'), config('wechat.encodingAESKey')); + 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, function($app) use ($service){ - return new $service(config('wechat.appId'), config('wechat.secret')); + $this->app->singleton([$service => $alias], function($app) use ($service){ + return new $service(config('wechat.app_id'), config('wechat.secret')); }); - - $this->app->alias($service, $alias); } } /** - * 提供的服务名称列表 + * 提供的服务 * * @return array */ public function provides() { - return array_keys($this->services) + array_values($this->services); + return $this->services; } } \ No newline at end of file