Multiple database read/write connections in Laravel
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
This post follows up on my previous post Multiple read-only database slaves in Laravel after I got a helpful comment from Ezequiel Russo who showed me an even better way to use multiple database read/write connections in Laravel - one that works with Laravel's config caching.
It turns out that Laravel will automatically pick a database connection at random if provided with an array, so there's no need to pick a random connection yourself. This makes it really easy to define your connections and have it work with php artisan config:cache
.