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).
Register the Bundle
Add the bundle to your Symfony kernel (config/bundles.php):
return [
// ...
AppDevPanel\Adapter\Symfony\Bundle\AdpBundle::class => ['all' => true],
];
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
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.
The adapter integrates with Symfony’s event dispatcher to collect:
kernel.request and kernel.response events).kernel.exception).dbal.connection.connect).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.
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.
}
}
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;
}
}
/slow-endpoint in your browser.var_dump() or inspect()).API Key Security
ADP_API_KEY in version control. Use Symfony’s parameter_bag or environment variables.Performance Overhead
.env:
ADP_ENABLED=false
ADP_SAMPLE_RATE=0.1 to log only 10% of requests.Doctrine DBAL Required for SQL Logging
doctrine/dbal:
composer require doctrine/dbal
Event Dispatcher Conflicts
kernel.request, ADP’s collector may run after it. Use priority:
$dispatcher->addListener(
KernelEvents::REQUEST,
[$collector, 'collect'],
EventPriority::HIGH
);
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.
Inspect Service Proxies Use Symfony’s debug toolbar to verify proxied services:
bin/console debug:container | grep adp
Custom Data Serialization
ADP uses PHP’s serialize() for complex objects. If data is lost:
__serialize()/__unserialize() in your objects.[Ignore] attributes (if using ADP’s API).Custom Collectors
Extend AppDevPanel\Api\Collector\CollectorInterface and tag with adp.collector:
class MyCollector implements CollectorInterface {
public function collect(): array {
return ['custom_data' => 'value'];
}
}
Override Inspector
Bind a custom inspector in services.yaml:
services:
AppDevPanel\Adapter\Symfony\Inspector\Inspector:
class: App\CustomInspector
Modify Payload Before Sending
Subscribe to adp.payload event:
$dispatcher->addListener('adp.payload', function ($payload) {
$payload['extra'] = 'data';
});
symfony/var-dumper for variable inspection.kernel.controller. Avoid manual middleware that skips ADP’s listeners.ADP_CACHE_TTL.How can I help you explore Laravel packages today?