Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Context;
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Context;
|
||||
|
||||
use App\Framework\Config\Environment;
|
||||
use App\Framework\Config\EnvKey;
|
||||
use App\Framework\Http\ServerEnvironment;
|
||||
|
||||
final readonly class ExecutionContext
|
||||
{
|
||||
private ServerEnvironment $serverEnvironment;
|
||||
|
||||
public function __construct(
|
||||
private ContextType $type,
|
||||
private array $metadata = []
|
||||
) {}
|
||||
) {
|
||||
$this->serverEnvironment = ServerEnvironment::fromGlobals();
|
||||
}
|
||||
|
||||
public function getType(): ContextType
|
||||
{
|
||||
@@ -35,7 +44,7 @@ final readonly class ExecutionContext
|
||||
return in_array($this->type, [
|
||||
ContextType::CONSOLE,
|
||||
ContextType::WORKER,
|
||||
ContextType::CLI_SCRIPT
|
||||
ContextType::CLI_SCRIPT,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -55,17 +64,32 @@ final readonly class ExecutionContext
|
||||
], $this->metadata);
|
||||
}
|
||||
|
||||
public static function detect(): self
|
||||
public static function detect(?Environment $environment = null): self
|
||||
{
|
||||
#$environment->get(EnvKey::APP_ENV);
|
||||
|
||||
// Debug logging
|
||||
#error_log("ExecutionContext::detect() - SAPI: " . php_sapi_name());
|
||||
#error_log("ExecutionContext::detect() - REQUEST_METHOD: " . ($_SERVER['REQUEST_METHOD'] ?? 'not set'));
|
||||
#error_log("ExecutionContext::detect() - HTTP_HOST: " . ($_SERVER['HTTP_HOST'] ?? 'not set'));
|
||||
#error_log("ExecutionContext::detect() - SERVER_NAME: " . ($_SERVER['SERVER_NAME'] ?? 'not set'));
|
||||
|
||||
// Test Environment
|
||||
if (defined('PHPUNIT_COMPOSER_INSTALL') ||
|
||||
isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] === 'testing') {
|
||||
error_log("ExecutionContext::detect() - Detected: TEST");
|
||||
|
||||
return new self(ContextType::TEST, ['detected_by' => 'phpunit_or_env']);
|
||||
}
|
||||
|
||||
// Web Request
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
return new self(ContextType::WEB, ['detected_by' => 'sapi']);
|
||||
// Web Request - Robustere Detection für Docker/nginx/php-fpm
|
||||
if (php_sapi_name() !== 'cli' ||
|
||||
isset($_SERVER['REQUEST_METHOD']) ||
|
||||
isset($_SERVER['HTTP_HOST']) ||
|
||||
isset($_SERVER['SERVER_NAME'])) {
|
||||
error_log("ExecutionContext::detect() - Detected: WEB");
|
||||
|
||||
return new self(ContextType::WEB, ['detected_by' => 'sapi_or_http_vars', 'sapi' => php_sapi_name()]);
|
||||
}
|
||||
|
||||
// CLI Detection
|
||||
@@ -80,10 +104,12 @@ final readonly class ExecutionContext
|
||||
default => ContextType::CLI_SCRIPT
|
||||
};
|
||||
|
||||
error_log("ExecutionContext::detect() - Detected: {$type->value} (CLI fallback)");
|
||||
|
||||
return new self($type, [
|
||||
'detected_by' => 'cli_analysis',
|
||||
'script_name' => $scriptName,
|
||||
'command_line' => $commandLine
|
||||
'command_line' => $commandLine,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user