- removed getenvonce, placed in env dir instead

This commit is contained in:
Dave Mc Nicoll 2026-06-15 20:19:44 +00:00
parent 77a13960f2
commit c181cdfb28

View File

@ -11,16 +11,13 @@ use League\Route\Strategy\ApplicationStrategy;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tell\I18n;
use Ulmus\Container\AdapterProxy;
use Laminas\Diactoros\ServerRequestFactory, use Laminas\Diactoros\ServerRequestFactory,
Laminas\HttpHandlerRunner\Emitter\EmitterInterface; Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
use Ulmus\Ulmus; use Ulmus\Ulmus;
class Kernel { class Kernel
{
protected Container $container; protected Container $container;
protected string $locale; protected string $locale;
@ -33,9 +30,11 @@ class Kernel {
public string $errorLogPath; public string $errorLogPath;
public function __construct( public function __construct(
public string $projectPath public string $projectPath
) { )
{
$this->setEnvironment(); $this->setEnvironment();
$this->initializeEngine(); $this->initializeEngine();
$this->setupContainer(); $this->setupContainer();
@ -49,7 +48,8 @@ class Kernel {
$_ENV[$var] = $value; $_ENV[$var] = $value;
} }
protected function setEnvironment() { protected function setEnvironment() : void
{
static::putenv('PROJECT_PATH', $this->projectPath); static::putenv('PROJECT_PATH', $this->projectPath);
// Environment vars (accessible from \DI\env(), getenv(), $_ENV and $_SERVER) // Environment vars (accessible from \DI\env(), getenv(), $_ENV and $_SERVER)
@ -57,6 +57,12 @@ class Kernel {
// Override using headers // Override using headers
if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) { if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) {
unset($_SERVER["HTTP_X_DEV_AUTH"]);
unset($_ENV[$name], $_SERVER[$name]);
putenv("KEYS=");
foreach(['APP_ENV', 'DEBUG',] as $env) { foreach(['APP_ENV', 'DEBUG',] as $env) {
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) { if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
static::putenv($env, $value); static::putenv($env, $value);
@ -154,7 +160,6 @@ class Kernel {
# Must be removed from KERNEL ! # Must be removed from KERNEL !
$this->container->has('ulmus.caching') and (Ulmus::$cache = $this->container->get('ulmus.caching')); $this->container->has('ulmus.caching') and (Ulmus::$cache = $this->container->get('ulmus.caching'));
# $this->container->has(AdapterProxy::class) and ( $ )
return $this; return $this;
} }
@ -177,4 +182,4 @@ class Kernel {
return $this; return $this;
} }
}; }