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

Pomm Symfony Bridge Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. 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).

  2. 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,
    ]);
    
  3. 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.


Implementation Patterns

1. Profiler Integration

  • Symfony Profiler Tab The bridge automatically adds a "Pomm" tab in the Symfony Profiler (or Silex’s debug toolbar). It logs:

    • Query execution time.
    • SQL statements.
    • Bound parameters.
    • Result counts.
  • Conditional Logging Disable in production by setting 'enabled' => false in config. Useful for performance-sensitive apps.

2. Customizing Data Collection

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;
        }
    };
});

3. Silex-Specific Workflows

  • Debug Toolbar Integration Ensure Silex’s 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());
    

4. Query Tagging

Tag queries for filtering in the profiler:

$client = $manager->getClient();
$client->query('SELECT * FROM users')
       ->withTag('auth'); // Tag for grouping in profiler

Gotchas and Tips

Pitfalls

  1. Profiler Tab Missing

    • Cause: Bridge not registered or 'enabled' => false.
    • Fix: Verify service registration and debug mode.
  2. SQL Not Displayed

    • Cause: Pomm’s Client not wrapped by the bridge.
    • Fix: Ensure all Client instances are obtained via $manager->getClient() (not manually instantiated).
  3. Performance Overhead

    • Cause: Enabled in production.
    • Fix: Set 'enabled' => env('APP_DEBUG') and clear cache after changes.
  4. Silex-Specific Issues

    • Cause: Profiler bundle not installed or misconfigured.
    • Fix: Confirm WebProfilerBundle is registered before the Pomm bridge.

Debugging Tips

  • 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).

Extension Points

  1. Custom Collectors Override PommCollector to log business-specific metrics (e.g., cache hits).

  2. 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);
    }
    
  3. Async Queries The bridge assumes synchronous queries. For async operations, implement a custom collector to log promises/results.

Config Quirks

  • Service ID Mismatch Ensure 'pomm.manager' in config matches your Pomm manager’s service ID (default: pomm.manager.default).
  • Caching Clear Symfony cache (php bin/console cache:clear) after changing bridge settings.
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky