di icon indicating copy to clipboard operation
di copied to clipboard

Dynamic bindings

Open samdark opened this issue 2 years ago • 2 comments

Container:

'connection' => [ ... ],
'connection2' => [ ... ],

bindings.php:

'ConnectionInterface' => [
  // When namespace starts with `App\Secondary`, pass `connection2` for `ConnectionInterface`.
  [
      'namespace' => 'App\Secondary',
      'definition' => Reference::to('connection2'),
  ],
  // When parameter name is `secondaryConnection`, pass `connection2` for `ConnectionInterface`.
  [
      'parameterName' => 'secondaryConnection',
      'definition' => Reference::to('connection2'),
  ],
],

samdark avatar May 24 '23 11:05 samdark

Using this feature may degrade overall container performance.

samdark avatar May 24 '23 11:05 samdark

// When parameter name is secondaryConnection, pass connection2 for ConnectionInterface. [ 'parameterName' => 'secondaryConnection', 'definition' => Reference::to('connection2'), ],

It's done in #352

xepozz avatar Feb 13 '24 18:02 xepozz