编写适配器
实现各功能的实际内容,初始化时会传入一个PoolInterface:
class MyAdapter {
	private $pool;
	public function __construct(PoolInterface $pool) {
		$this->pool = $pool;
	}
}
 1
2
3
4
5
6
7
2
3
4
5
6
7
在Pool上注册:
namespace YesfApp;
use Yesf\Connection\Pool;
class Configuration {
	public function setPool() {
		// myadapter是名称,可随意定义
		Pool::setAdapter('myadapter', MyAdapter::class);
	}
}
 1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
接下来,在配置中这样使用:
connection.my.adapter=myadapter
 1