lumen-5.3

How to use multiple database in Lumen

依然范特西╮ 提交于 2019-12-21 02:46:21
问题 We've using Lumen for building API's , Now we need to access multiple databases. Currently using .env for database config but unable to found the way to multiple databases in .env where we need to read 2nd connection ... 回答1: First, you'll need to configure your connections. If you don't already have one you'll need to create a config directory in your project and add the file config/database.php . It might look like this: <?php return [ 'default' => 'accounts', 'connections' => [ 'mysql' =>

How to use multiple database in Lumen

旧巷老猫 提交于 2019-12-03 08:47:40
We've using Lumen for building API's , Now we need to access multiple databases. Currently using .env for database config but unable to found the way to multiple databases in .env where we need to read 2nd connection ... First, you'll need to configure your connections. If you don't already have one you'll need to create a config directory in your project and add the file config/database.php . It might look like this: <?php return [ 'default' => 'accounts', 'connections' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST'), 'port' => env('DB_PORT'), 'database' => env('DB_DATABASE'),