database icon indicating copy to clipboard operation
database copied to clipboard

Allow to use any injection name if there is only 1 database

Open vladgorenkin opened this issue 4 years ago • 1 comments

It'd be great if we could use db or database (or any other name) as argument names if there is only one database declared. Currently you have to use default database name as an injection argument:

// database config
return [
    'default' => 'default',
   'databases' => [
        'default' => [
            'driver' => 'postgres',
        ],
   ],
   ...
]

// some service
public function __construct(private DatabaseInterface $default) {}

private DatabaseInterface $db would throw an exception: db preset was not found.

vladgorenkin avatar Jun 15 '21 08:06 vladgorenkin

Interesting sugar addition. Thank you

wolfy-j avatar Jun 15 '21 10:06 wolfy-j