Mayowa Emmanuel Oludare 1 hour ago· 1 min readHow to Set Database Configuration Dynamically in your Laravel Application. Sometimes we may find ourselves in situations where we have to modify our database connection/configuration at runtime. Some applications require alot of database and sometimes the required database can only be determined at runtime. A typical example from my experience was in School Management System that required a separate Database for each school.

A better approach is to only modify only the configuration array key of interest, in this case the database name of your mysql connection.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners