## 安装
Easyswoole提供的一个全新协程安全的ORM封装。
依赖关系
* swoole`>= 4.4.8`
* Easyswoole`>=3.3.2`
* mysqli >`2.x`
~~~php
composer require easyswoole/orm
~~~
## 配置
/dev.php文件中加入以下配置
```
'MYSQL' => [
'host' => '127.0.0.1',
'port' => 3306,
'user' => '',
'password'=> '',
'database'=> '',
'timeout' => 5,
'charset' => 'utf8mb4'
],
```
/EasySwooleEvent.php 文件中mainServerCreate方法加入以下代码
```
namespace EasySwoole\EasySwoole;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use EasySwoole\ORM\Db\Connection;
use EasySwoole\ORM\DbManager;
class EasySwooleEvent implements Event
{
public static function initialize()
{
// TODO: Implement initialize() method.
date_default_timezone_set('Asia/Shanghai');
}
public static function mainServerCreate(EventRegister $register)
{
$config = new \EasySwoole\ORM\Db\Config(Config::getInstance()->getConf('MYSQL'));
DbManager::getInstance()->addConnection(new Connection($config));
// 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.
}
```