<?php declare (strict_types=1); namespace app; use app\listener\wechat\OffcialAccountListener; use app\listener\wechat\OpenPlatformListener; use app\listener\wechat\RoutineListener; use app\services\system\config\SystemConfigServices; use qiniu\services\wechat\config\HttpCommonConfig; use qiniu\services\wechat\MiniProgram; use qiniu\services\wechat\OfficialAccount; use qiniu\services\wechat\OpenPlatform; use qiniu\services\SystemConfigService; use GuzzleHttp\DefaultHandler; use qiniu\utils\Json; use think\Service; use Yurun\Util\Swoole\Guzzle\SwooleHandler; /** * 应用服务类 */ class AppService extends Service { public $bind = [ 'json' => Json::class, 'sysConfig' => SystemConfigService::class, ]; public function register() { // 服务注册 //http配置服务 $this->app->bind(HttpCommonConfig::class, function () { return (new HttpCommonConfig())->setServe(SystemConfigServices::class); }); //公众号 $this->app->bind(OfficialAccount::class, function () { return (new OfficialAccount)->setPushMessageHandler(OffcialAccountListener::class); }); //小程序 $this->app->bind(MiniProgram::class, function () { return (new MiniProgram)->setPushMessageHandler(RoutineListener::class); }); //开放平台 $this->app->bind(OpenPlatform::class, function () { return (new OpenPlatform)->setPushMessageHandler(OpenPlatformListener::class); }); } public function boot() { defined('DS') || define('DS', DIRECTORY_SEPARATOR); DefaultHandler::setDefaultHandler(SwooleHandler::class); } }