/** * Registers services on the given container. * * This method should only be used to configure services and parameters. * It should not get services. * * @param Container $pimple A container instance */ public function register(Container $pimple) { $pimple['encryptor'] = function ($pimple) { return new Encryptor($pimple['config']['app_id'], $pimple['config']['token'], $pimple['config']['aes_key']); }; $pimple['server'] = function ($pimple) { $server = new Guard(); $server->setEncryptor($pimple['encryptor']); return $server; }; }
private function registerServer() { $this->app->singleton('wechat.encryptor', function () { return new Encryptor(config('wechat.app_id'), config('wechat.token'), config('wechat.aes_key')); }); $this->app->singleton('wechat.server', function () { $server = new Guard(app('request')); $server->setEncryptor(app('wechat.encryptor')); return $server; }); }