I am using Lumen 5.3.1. $app->withFacades() and $app->withEloquent() have been uncommented in app.php. In web.php I run the following code:
$app->get('foo', function () {
return app('db')->select("SELECT * FROM foo");
return "Connected successfully to database " . DB::connection()->getDatabaseName();
});
The select() call correctly returns data from the foo table. However, DB::connection() returns:
FatalErrorException in Manager.php line 74:
Call to a member function getConnection() on null
Why does one work but not the other?