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

Symfony Roadrunner Dumper Laravel Package

alshenetsky/symfony-roadrunner-dumper

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require --dev alshenetsky/symfony-roadrunner-dumper "^1.0"
    

    Ensure you’re in a dev dependency context (e.g., require-dev in composer.json).

  2. First Use Case: Replace any dd() calls in your Symfony/Laravel + Roadrunner app with:

    \dev\dd($yourVariable);
    

    This avoids the worker error: invalid data found in the buffer issue in Roadrunner.

  3. Where to Look First:


Implementation Patterns

Core Workflow

  1. Debugging in Roadrunner:

    • Use \dev\dd() exclusively in Roadrunner-powered Symfony/Laravel apps to bypass buffer issues.
    • Example:
      // Controller/Command
      public function index() {
          $data = $this->fetchData();
          \dev\dd($data); // Works in Roadrunner
      }
      
  2. Integration with Symfony Components:

    • Works seamlessly with Symfony’s VarDumper (under the hood). No config changes needed.
    • Compatible with Symfony 3.3+, 4.x, and 5.x.
  3. Laravel Adaptation:

    • If using Laravel, alias \dev\dd in app/Console/Kernel.php or a service provider:
      use function Alshenetsky\SymfonyRoadrunnerDumper\dd;
      
      // Alias for convenience
      if (!function_exists('dev_dd')) {
          function dev_dd($var) { dd($var); } // Override or extend
      }
      
  4. Async/Queue Debugging:

    • Dump variables in Roadrunner workers (e.g., queue jobs) without breaking output:
      // In a Roadrunner worker (e.g., queue listener)
      \dev\dd($message->payload); // Safe for async contexts
      
  5. Testing:

    • Use in PHPUnit tests running under Roadrunner (e.g., Pest or Laravel’s testing suite).

Gotchas and Tips

Pitfalls

  1. Buffer Conflicts:

    • Original dd() fails in Roadrunner because it echoes directly to STDOUT, which Roadrunner’s workers don’t handle.
    • Fix: Always use \dev\dd() in Roadrunner environments.
  2. Dev vs. Prod:

    • The package is dev-only (installed via require-dev). Ensure it’s excluded from production builds.
  3. Symfony Context:

    • If using Symfony Flex, autoloading should work out-of-the-box. For custom setups, verify the autoload-dev section in composer.json includes:
      "autoload-dev": {
          "psr-4": {
              "Alshenetsky\\SymfonyRoadrunnerDumper\\": "vendor/alshenetsky/symfony-roadrunner-dumper/src/"
          }
      }
      
  4. Roadrunner Worker Logs:

    • Dumps appear in Roadrunner’s worker logs (not browser output). Check:
      rr get-worker-log
      
      or configure logging in rr.yaml.

Debugging Tips

  1. Verify Installation:

    • Run composer dump-autoload --dev if \dev\dd is not recognized.
  2. Custom Output:

    • Override the dumper’s output format by extending the underlying VarDumper:
      use Symfony\Component\VarDumper\Cloner\Data;
      use Symfony\Component\VarDumper\Dumper\CliDumper;
      
      $dumper = new CliDumper();
      $dumper->dump(new Data($yourVariable));
      
  3. Performance:

    • Avoid \dev\dd() in hot paths (e.g., loops). Use sparingly in dev environments.
  4. Laravel-Specific:

    • If using Laravel, ensure the dev namespace is accessible. Add to composer.json:
      "extra": {
          "laravel": {
              "providers": ["Alshenetsky\\SymfonyRoadrunnerDumper\\SymfonyRoadrunnerDumperServiceProvider"]
          }
      }
      

Extension Points

  1. Custom Dumper:

    • Extend the dumper to add features (e.g., JSON output, file logging):
      namespace App\Dumper;
      
      use Alshenetsky\SymfonyRoadrunnerDumper\Dumper;
      
      class CustomDumper extends Dumper {
          public function dump($var) {
              file_put_contents('debug.log', print_r($var, true));
          }
      }
      
  2. Roadrunner Config:

    • Adjust Roadrunner’s rr.yaml to handle dumps:
      server:
        command: "php bin/console"
        relay: "pipes"
      worker:
        pool:
          num_workers: 4
        # Log dumps to a file
        log: "/var/log/roadrunner/debug.log"
      
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle