1tomany/postgres-bundle
Symfony bundle that enhances Doctrine DBAL for PostgreSQL. Provides an advisory lock manager and optional middleware to set the connection time zone. Auto-wires to the default Doctrine connection, with simple YAML configuration overrides.
Architecture fit
The 1tomany/postgres-bundle introduces PostgreSQL-specific advisory lock enhancements tailored for Symfony/Doctrine, which can be adapted to Laravel via Doctrine ORM integration. Its iterative lock release feature is a critical fit for Laravel applications requiring:
Key architectural strengths:
UTC) simplifies distributed systems.Integration feasibility
spatie/laravel-doctrine-orm or Symfony bridge).user:123:profile) for iterative releases.AdvisoryLockManager.unlockPartial()).Technical risk
lock('A:B') + lock('B:A')).BEGIN/COMMIT rollbacks.Key questions
unlockPartial() persist across ROLLBACK?)unlockPartial() reset the TTL?)getActiveSegments())?AdvisoryLockManager to Laravel’s service container?Stack fit
spatie/laravel-doctrine-orm or manual Symfony bridge setup.AdvisoryLockManager; bind to Laravel’s container using:
$this->app->bind('advisory_lock_manager', function ($app) {
return new \Onetomany\PostgresBundle\Lock\AdvisoryLockManager(
$app['dbal.connection'],
$app['onetomany_postgres.config']
);
});
Migration path
spatie/laravel-doctrine-orm and symfony/dom-coder if not using Symfony.postgresql.conf (if needed).composer require 1tomany/postgres-bundle symfony/dom-coder
onetomany_postgres.yaml to config/packages/:
onetomany_postgres:
advisory_lock_manager:
connection: "pgsql" # Laravel's DB connection name
middleware:
time_zone: "UTC"
AppServiceProvider:
public function register()
{
$this->app->register(\Onetomany\PostgresBundle\PostgresBundle::class);
}
// Before
DB::select("SELECT pg_advisory_lock(12345)");
// After
$lockManager = $this->app->make('advisory_lock_manager');
$lockManager->acquire('user:123:profile');
user:123:profile).acquire(), unlockPartial(), and release() methods.pg_advisory_lock timeouts).Compatibility
Semaphore, Redis).LockManager extensions) may need updates.Sequencing
AdvisoryLockException) and PostgreSQL logs (pg_stat_activity).v0.0.7 if partial releases introduce instability.if (config('features.iterative_locks')) {
$lockManager->unlockPartial('profile');
} else {
$lockManager->release();
}
Maintenance
user:123:orders still locked?").
$lockManager->setLogger($this->app->make('logger'));
SELECT * FROM pg_stat_activity WHERE locktype = 'advisory';
onetomany_postgres.yaml.Support
resource:type:id).
user:123:profile, order:456:inventory.// Multi-step payment processing
$lockManager->acquire('payment:789');
try {
$lockManager->unlockPartial('authorization'); // Release after auth
// Process payment...
$lockManager->unlockPartial('capture'); // Release after capture
} catch (\Exception $e) {
$lockManager->release(); // Full release on failure
}
AdvisoryLockTimeoutException).pg_advisory_lock).Scaling
How can I help you explore Laravel packages today?