I'm new to laravel. I've just started and I am trying to have 2 different database config details in Laravel but don't have any idea as to where to start.
As I am trying out laravel on my local machine I want to save local database info. and when uploaded the laravel to hosting then it should use the other info. So I don't have to juggle between the both and can just concentrate on learning and coding.
Can anyone help as to how can I do that in Laravel ?
I wouldn't do that if were you, just run your local dev setup, and then when it's time to deploy you configure the app on the remote machine. If you need to copy any data then use mysql dump.
@kikloo You don’t have “two configs”. You use an .env file to specify the connection details for that particular environment.
So locally, you put your local database’s connection details. When you deploy your site, you deploy it to a server that has its own .env file that has the connection details of your live database.
Never mix connections between environments. Because one day you will run a command on the wrong database that may be disastrous: such as dropping or truncating a table, or even the entire database if you accidentally run something like php artisan migrate:fresh on your live database. It could also even fall foul of data protection laws in your country if you’re pulling sensitive information of people onto computers that it doesn’t need to be on.