mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 00:25:35 +08:00
add environment variables support (#255)
This commit is contained in:
@@ -7,6 +7,7 @@ use OneBot\Driver\Coroutine\CoroutineInterface;
|
||||
use OneBot\Driver\Process\ExecutionResult;
|
||||
use OneBot\V12\Object\MessageSegment;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use ZM\Config\Environment;
|
||||
use ZM\Config\ZMConfig;
|
||||
use ZM\Container\ContainerHolder;
|
||||
use ZM\Logger\ConsoleLogger;
|
||||
@@ -268,3 +269,12 @@ function kv(string $name = ''): Psr\SimpleCache\CacheInterface
|
||||
/* @phpstan-ignore-next-line */
|
||||
return is_a($kv_class, KVInterface::class, true) ? $kv_class::open($name) : new $kv_class($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取环境变量
|
||||
*/
|
||||
function env(string $key, mixed $default = null): mixed
|
||||
{
|
||||
// TODO: 重新思考容器绑定的加载方式,从而在此处使用 interface
|
||||
return resolve(Environment::class)->get($key, $default);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user