This commit is contained in:
jhx
2022-08-30 11:18:07 +08:00
parent 1689dfffe9
commit e367f4b8d1
5 changed files with 659 additions and 2 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
/**
*
* @author jhx
* @date 2021/9/28 15:45
*/
namespace app\server;
use GuzzleHttp\Client;
class GuzzleServer
{
public function __construct()
{
}
/**
* singleton
*/
protected static $instanceClient = null;
/**
* destruct.
*/
public function __destruct()
{
static::$instanceClient = null;
}
/**
* 获取单例
* @param array $config 配置参数
*/
public static function getClient($config = []): Client
{
if (!(static::$instanceClient instanceof Client)) {
static::$instanceClient = new Client($config);
}
return static::$instanceClient;
}
}