Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Infra Test Bundle Laravel Package

dayploy/infra-test-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require dayploy/infra-test-bundle
    

    Register the bundle in config/bundles.php:

    return [
        // ...
        Dayploy\InfraTestBundle\DayployInfraTestBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Debugging Kubernetes Pods

    • Run the command to generate logs directly in a pod:
      ./bin/console infra >> /proc/1/fd/1
      
    • For local testing, use:
      ./bin/console infra --env=test
      
  3. Key Files to Review

    • config/packages/dayploy_infra_test.yaml (default config)
    • src/Command/InfraCommand.php (core logic)
    • tests/ (if available, for edge cases)

Implementation Patterns

Workflow: Debugging in CI/CD

  1. 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
    
    • Use --format (json, yaml, or table) for structured output.
  2. Custom Log Paths Override default /proc/1/fd/1 in config:

    dayploy_infra_test:
        log_path: '/var/log/app/debug.log'
    
  3. 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();
    }
    
  4. Testing Infrastructure Use in PHPUnit tests:

    public function testPodLogs() {
        $this->executeCommand('infra', ['--env=test']);
        $this->assertStringContainsString('test output', $output);
    }
    

Gotchas and Tips

Pitfalls

  1. Permissions in Kubernetes

    • Ensure the pod service account has read access to /proc/1/fd/1.
    • Debug with:
      kubectl exec -it <pod> -- cat /proc/1/fd/1
      
  2. Environment-Specific Config

    • Override config per environment (e.g., config/packages/dev/dayploy_infra_test.yaml).
    • Avoid hardcoding paths in shared configs.
  3. Command Output Buffering

    • Use --no-interaction in CI to prevent TTY prompts:
      ./bin/console infra --no-interaction --format=json > infra.log
      

Debugging Tips

  • 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'
    

Extension Points

  1. 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
        }
    }
    
  2. 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']);
    }
    
  3. Support Non-Kubernetes Environments Override supportsEnvironment() in InfraCommand to add logic for Docker, VMs, etc.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
baks-dev/finances
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle