Laravel
Gold Lapel ships Laravel support inside the PHP wrapper — no separate plugin to install. Composer require, and Laravel's package auto-discovery wires the rest.
Install
composer require goldlapel/goldlapel Laravel's package auto-discovery (5.5+) registers the service provider for you — no entry in config/app.php required, no config to publish.
Use
All PostgreSQL connections route through Gold Lapel automatically. The L1 native cache activates with the proxy — repeated reads serve in microseconds. Eloquent models, the query builder, eager-loaded relationships, and artisan migrate all flow through unchanged.
Add a goldlapel key under any connection in config/database.php to tune settings or to disable the proxy for that connection:
// config/database.php
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'goldlapel' => [
'enabled' => true,
'port' => 7932,
'config' => [
'mode' => 'waiter',
'pool_size' => 50,
],
'extra_args' => [],
],
], Configuration
| Key | Default | Description |
|---|---|---|
goldlapel.enabled | true | Set to false to disable the proxy on this connection |
goldlapel.port | 7932 | Local proxy port |
goldlapel.config | [] | Full Gold Lapel config array (same keys as GoldLapel::start($url, config: ...)) |
goldlapel.extra_args | [] | Extra CLI args passed to the Gold Lapel binary |
The config array takes the same keys as GoldLapel::start($url, config: ...) — see the configuration reference for every setting.
Multiple databases
Each proxied connection wants its own port:
'primary' => [
'driver' => 'pgsql',
'host' => 'db1.example.com',
'goldlapel' => ['port' => 7932],
],
'analytics' => [
'driver' => 'pgsql',
'host' => 'db2.example.com',
'goldlapel' => ['port' => 7942],
], Tenancy packages, read/write replica arrays, and custom connection resolvers continue to work — each connection carries its own Gold Lapel instance.
Tuning
extra_args passes any Gold Lapel CLI flag through to the proxy. For settings that vary by environment, GOLDLAPEL_* environment variables are honoured as well.
Requirements
- PHP 8.1+
- Laravel 10+
goldlapel/goldlapel0.2+- PostgreSQL (TCP connections)
How it works
The auto-discovered service provider runs at boot. For each PostgreSQL connection with Gold Lapel enabled, it:
- Builds the upstream database URL from your connection config
- Calls
GoldLapel::startProxyOnly()— Laravel manages its own PDO pool, so only the proxy is spawned - Rewrites the connection's host and port to the local proxy and registers a custom
Connectionresolver that wraps the PDO with the L1 native cache
Eloquent, the query builder, Artisan commands, and raw DB:: calls all route through the wrapped connection.
For the underlying PHP wrapper API — GoldLapel::start(), PDO helpers, and the wrapper methods — see the PHP guide.