-
Notifications
You must be signed in to change notification settings - Fork 33
/
EasySwooleEvent.php
46 lines (38 loc) · 1.24 KB
/
EasySwooleEvent.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace EasySwoole\EasySwoole;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use EasySwoole\EasySwoole\Config as GlobalConfig;
use Illuminate\Database\Capsule\Manager as Capsule;
class EasySwooleEvent implements Event
{
public static function initialize()
{
// TODO: Implement initialize() method.
date_default_timezone_set('Asia/Shanghai');
// 初始化数据库
$dbConf = GlobalConfig::getInstance()->getConf('database');
$capsule = new Capsule;
// 创建链接
$capsule->addConnection($dbConf);
// 设置全局静态可访问
$capsule->setAsGlobal();
// 启动Eloquent
$capsule->bootEloquent();
}
public static function mainServerCreate(EventRegister $register)
{
// TODO: Implement mainServerCreate() method.
}
public static function onRequest(Request $request, Response $response): bool
{
// TODO: Implement onRequest() method.
return true;
}
public static function afterRequest(Request $request, Response $response): void
{
// TODO: Implement afterAction() method.
}
}