get(Redis::class); } } /** * server 实例 基于 swoole server */ if (!function_exists('server')) { function server() { return container()->get(ServerFactory::class)->getServer()->getServer(); } } /** * websocket frame 实例 */ if (!function_exists('frame')) { function frame() { return container()->get(Frame::class); } } /** * websocket 实例 */ if (!function_exists('websocket')) { function websocket() { return container()->get(WebSocketServer::class); } } /** * 缓存实例 简单的缓存 */ if (!function_exists('cache')) { function cache() { return container()->get(Psr\SimpleCache\CacheInterface::class); } } /** * 控制台日志 */ if (!function_exists('stdLog')) { function stdLog() { return container()->get(StdoutLoggerInterface::class); } } /** * 文件日志 */ if (!function_exists('logger')) { function logger() { return container()->get(LoggerFactory::class)->make(); } } /** * http 请求实例 */ if (!function_exists('request')) { function request() { return container()->get(ServerRequestInterface::class); } } /** * 请求响应 */ if (!function_exists('response')) { function response() { return container()->get(ResponseInterface::class); } } /** * 获取加密后的密码字符 * * @param string $password * @return bool|false|null|string */ function create_password(string $password){ return password_hash($password, PASSWORD_DEFAULT); }