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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners