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

Adapter Symfony Laravel Package

app-dev-panel/adapter-symfony

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Package

    composer require app-dev-panel/adapter-symfony
    

    Ensure app-dev-panel/api, app-dev-panel/kernel, and app-dev-panel/cli are also installed (they are listed as strict dependencies).

  2. Register the Bundle Add the bundle to your Symfony kernel (config/bundles.php):

    return [
        // ...
        AppDevPanel\Adapter\Symfony\Bundle\AdpBundle::class => ['all' => true],
    ];
    
  3. Configure Environment Variables Add these to your .env:

    ADP_API_URL=https://your-adp-instance.com/api
    ADP_API_KEY=your_api_key_here
    ADP_ENV=development
    
  4. First Use Case: Debugging HTTP Requests The adapter auto-wires Symfony’s HttpKernel events to collect request/response data. No manual configuration is needed for basic debugging—just trigger a request and inspect the ADP dashboard.


Implementation Patterns

Auto-Wiring Debug Collectors

The adapter integrates with Symfony’s event dispatcher to collect:

  • HTTP Requests/Responses (via kernel.request and kernel.response events).
  • Exceptions (via kernel.exception).
  • Database Queries (if Doctrine is installed, via dbal.connection.connect).
  • Logs (via monolog.logger events).

Example: Extending Collectors To add custom data (e.g., Redis calls), create a collector service and tag it with adp.collector:

# config/services.yaml
services:
    App\Collector\RedisCollector:
        tags: ['adp.collector']

Implement AppDevPanel\Api\Collector\CollectorInterface.


Inspector Integration

The adapter proxies Symfony services (e.g., ContainerInterface, ParameterBag) to ADP’s inspector. Use the adp.inspector service to introspect:

use AppDevPanel\Adapter\Symfony\Inspector\Inspector;

class MyController {
    public function __construct(private Inspector $inspector) {}

    public function debug(Request $request) {
        $this->inspector->inspect($request->query->all());
        // Data is sent to ADP automatically.
    }
}

CLI and Command-Line Debugging

For Symfony commands, use the adp.cli service to log command execution:

use AppDevPanel\Adapter\Symfony\Cli\Cli;

class MyCommand extends Command {
    public function __construct(private Cli $cli) {}

    protected function execute(InputInterface $input, OutputInterface $output): int {
        $this->cli->start('my_command');
        // ... command logic ...
        $this->cli->stop();
        return Command::SUCCESS;
    }
}

Workflow: Debugging a Slow Endpoint

  1. Trigger the Request: Visit /slow-endpoint in your browser.
  2. Inspect in ADP: The request/response, SQL queries, and logs appear in the ADP dashboard under "Requests".
  3. Drill Down: Click a request to see:
    • Timing breakdowns (PHP, DB, network).
    • Variable dumps (via var_dump() or inspect()).
    • Exception traces (if any).

Gotchas and Tips

Pitfalls

  1. API Key Security

    • Never hardcode ADP_API_KEY in version control. Use Symfony’s parameter_bag or environment variables.
    • Restrict ADP’s IP in your firewall if exposing it publicly.
  2. Performance Overhead

    • ADP collects all HTTP requests by default. For production, disable in .env:
      ADP_ENABLED=false
      
    • Use ADP_SAMPLE_RATE=0.1 to log only 10% of requests.
  3. Doctrine DBAL Required for SQL Logging

    • If using Doctrine ORM but not DBAL, SQL queries won’t be logged. Install doctrine/dbal:
      composer require doctrine/dbal
      
  4. Event Dispatcher Conflicts

    • If another bundle listens to kernel.request, ADP’s collector may run after it. Use priority:
      $dispatcher->addListener(
          KernelEvents::REQUEST,
          [$collector, 'collect'],
          EventPriority::HIGH
      );
      

Debugging Tips

  1. Verify Data is Sent Check ADP’s "Logs" tab for adp.* entries. If empty, the adapter isn’t firing:

    bin/console debug:event-dispatcher kernel.request
    

    Ensure AppDevPanel\Adapter\Symfony\EventListener\AdpListener is subscribed.

  2. Inspect Service Proxies Use Symfony’s debug toolbar to verify proxied services:

    bin/console debug:container | grep adp
    
  3. Custom Data Serialization ADP uses PHP’s serialize() for complex objects. If data is lost:

    • Implement __serialize()/__unserialize() in your objects.
    • Use [Ignore] attributes (if using ADP’s API).

Extension Points

  1. Custom Collectors Extend AppDevPanel\Api\Collector\CollectorInterface and tag with adp.collector:

    class MyCollector implements CollectorInterface {
        public function collect(): array {
            return ['custom_data' => 'value'];
        }
    }
    
  2. Override Inspector Bind a custom inspector in services.yaml:

    services:
        AppDevPanel\Adapter\Symfony\Inspector\Inspector:
            class: App\CustomInspector
    
  3. Modify Payload Before Sending Subscribe to adp.payload event:

    $dispatcher->addListener('adp.payload', function ($payload) {
        $payload['extra'] = 'data';
    });
    

Config Quirks

  • Symfony 6.4+ Required: Uses symfony/var-dumper for variable inspection.
  • PSR-15 Middleware: ADP auto-wires middleware via kernel.controller. Avoid manual middleware that skips ADP’s listeners.
  • Caching: ADP caches payloads for 5 minutes by default. Adjust with ADP_CACHE_TTL.
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