
使用 hyperf 已经有一段时间了,下面是一些常用的助手函数,分享一下~~~
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();
}
}
/**
*
*/
if (!function_exists('request')) {
function request()
{
return container()->get(ServerRequestInterface::class);
}
}
/**
*
*/
if (!function_exists('response')) {
function response()
{
return container()->get(ResponseInterface::class);
}
}推荐教程:《PHP教程》
微厦在线学习云服务平台 2.0是一款基于B/S架构的在线教育系统,将“在线视频学习、在线试题练习、在线同步考试”紧密相联,打造“学、练、考”于一体的在线教育系统,能够利用电脑、手机、微信等多种设备进行学习,方便学员利用碎片化时间进行随时随地的学习。并带有“分享、分润、分销”的辅助功能,对于平台推广、课程销售起到非常有效的帮助。适用类别:个人、单位、老师、大学、教育机构适用行业:企业培训、教育机构、









