Retrieving Laravel's Current Database Name

Database Debugging Testing

Committed to the LaraBrain by: wjgilmore (@wjgilmore) at March 8, 2016 4:16 pm

When troubleshooting database connectivity it can be useful to log the current database name

Every once in a while I'll run into a weird issue in which I want to quickly confirm which database my Laravel application thinks it is supposed to be using. To retrieve this name you'll call the DB library's getDatabaseName() method:

\Log::info(\DB::getDatabaseName());

Then just tail your application's storage/logs/laravel.log file to see the result.