pomm-project/pomm-symfony-bridge
Symfony bundle bridging Pomm (PostgreSQL Object Model Manager) into Symfony apps. Provides DI integration, configuration and service setup to access Pomm sessions and database connections cleanly from your Symfony services.
Installation Add the package via Composer:
composer require pomm-project/pomm-symfony-bridge
Ensure your project uses Symfony 3.x–5.x (or Silex if bridging both).
Basic Setup The package bridges PommProject (a PostgreSQL ORM) with Symfony’s Profiler for debugging. Register the bridge in your Symfony kernel or Silex app:
// config/packages/pomm_symfony_bridge.php (Symfony)
return [
'pomm_symfony_bridge' => [
'enabled' => env('APP_DEBUG', false),
'pomm_manager' => 'pomm.manager.default', // Your Pomm manager service ID
],
];
Or in Silex:
$app->register(new \PommProject\SymfonyBridge\BridgeServiceProvider(), [
'pomm.manager' => $pommManager,
]);
First Use Case: Debugging Queries
Enable the profiler in config/packages/dev/profiler.yaml:
framework:
profiler: { only_exceptions: false }
Now, Pomm queries will appear in the Profiler’s "Pomm" tab, showing execution time, SQL, and parameters.
Symfony Profiler Tab The bridge automatically adds a "Pomm" tab in the Symfony Profiler (or Silex’s debug toolbar). It logs:
Conditional Logging
Disable in production by setting 'enabled' => false in config. Useful for performance-sensitive apps.
Extend the default collector to log additional metadata:
use PommProject\SymfonyBridge\Collector\PommCollector;
// Override the collector service
$container->set('pomm_symfony_bridge.collector', function () use ($container) {
$collector = new class($container->get('pomm.manager')) extends PommCollector {
public function collect(): array {
$data = parent::collect();
$data['custom_metric'] = 'your_value'; // Add custom data
return $data;
}
};
});
WebProfilerBundle is installed:
composer require symfony/web-profiler-bundle
Register the bridge after the profiler bundle:
$app->register(new \Symfony\Bundle\WebProfilerBundle\SilexProvider());
$app->register(new \PommProject\SymfonyBridge\BridgeServiceProvider());
Tag queries for filtering in the profiler:
$client = $manager->getClient();
$client->query('SELECT * FROM users')
->withTag('auth'); // Tag for grouping in profiler
Profiler Tab Missing
'enabled' => false.SQL Not Displayed
Client not wrapped by the bridge.Client instances are obtained via $manager->getClient() (not manually instantiated).Performance Overhead
'enabled' => env('APP_DEBUG') and clear cache after changes.Silex-Specific Issues
WebProfilerBundle is registered before the Pomm bridge.Log Raw Queries Temporarily enable Pomm’s debug mode:
$manager->getConfiguration()->setDebug(true);
Queries will log to stdout (useful for CLI debugging).
Filter Profiler Data
Use the profiler’s search bar to filter by tags (e.g., auth).
Custom Collectors
Override PommCollector to log business-specific metrics (e.g., cache hits).
Query Formatting
Modify SQL display by extending PommCollector and overriding formatQuery():
public function formatQuery(string $sql): string {
return str_replace('SELECT', '<span class="highlight">SELECT</span>', $sql);
}
Async Queries The bridge assumes synchronous queries. For async operations, implement a custom collector to log promises/results.
'pomm.manager' in config matches your Pomm manager’s service ID (default: pomm.manager.default).php bin/console cache:clear) after changing bridge settings.How can I help you explore Laravel packages today?