Installation
composer require dayploy/infra-test-bundle
Register the bundle in config/bundles.php:
return [
// ...
Dayploy\InfraTestBundle\DayployInfraTestBundle::class => ['all' => true],
];
First Use Case: Debugging Kubernetes Pods
./bin/console infra >> /proc/1/fd/1
./bin/console infra --env=test
Key Files to Review
config/packages/dayploy_infra_test.yaml (default config)src/Command/InfraCommand.php (core logic)tests/ (if available, for edge cases)Integrate with CI Scripts
Add to .github/workflows/test.yml:
jobs:
test:
runs-on: ubuntu-latest
steps:
- run: ./bin/console infra --env=ci --format=json
--format (json, yaml, or table) for structured output.Custom Log Paths
Override default /proc/1/fd/1 in config:
dayploy_infra_test:
log_path: '/var/log/app/debug.log'
Symfony Event Integration
Listen to kernel.terminate to auto-log errors:
// src/EventListener/InfraLoggerListener.php
public function onTerminate(GetResponseForControllerResultEvent $event) {
$logger = $this->container->get('dayploy_infra_test.logger');
$logger->logSystemState();
}
Testing Infrastructure Use in PHPUnit tests:
public function testPodLogs() {
$this->executeCommand('infra', ['--env=test']);
$this->assertStringContainsString('test output', $output);
}
Permissions in Kubernetes
/proc/1/fd/1.kubectl exec -it <pod> -- cat /proc/1/fd/1
Environment-Specific Config
config/packages/dev/dayploy_infra_test.yaml).Command Output Buffering
--no-interaction in CI to prevent TTY prompts:
./bin/console infra --no-interaction --format=json > infra.log
Verbose Mode
./bin/console infra -vvv
Reveals internal logging and file operations.
Custom Logging Extend the logger class:
// src/Service/ExtendedInfraLogger.php
class ExtendedInfraLogger extends \Dayploy\InfraTestBundle\Logger {
public function logCustomMetric(string $name, $value) {
// ...
}
}
Bind it in services.yaml:
Dayploy\InfraTestBundle\Logger: '@extended_infra_logger'
Add Custom Commands
Extend InfraCommand to support new actions:
// src/Command/CustomInfraCommand.php
class CustomInfraCommand extends InfraCommand {
protected function configure() {
$this->setName('infra:custom');
}
protected function execute(InputInterface $input, OutputInterface $output) {
// Custom logic
}
}
Hook into Log Generation
Subscribe to dayploy.infra.log.generated event:
// src/EventSubscriber/LogSubscriber.php
public static function getSubscribedEvents() {
return [
'dayploy.infra.log.generated' => 'onLogGenerated',
];
}
public function onLogGenerated(LogGeneratedEvent $event) {
$event->getLog()->addMetadata(['custom' => 'data']);
}
Support Non-Kubernetes Environments
Override supportsEnvironment() in InfraCommand to add logic for Docker, VMs, etc.
How can I help you explore Laravel packages today?