Where do I keep my database details?

I am able to connect with my database having these in local.php but as soon as I deploy it then the system is unable to get from local.php, I will have to add it to module.config.php.

What is the best approach to keep DB related or global configs?

I have followed this: https://github.com/laminas-api-tools/statuslib-example

The error it is throwing after deploying is this:

Service with name “StatusLib\TableGateway” could not be created. Reason: Unable to create StatusLib\TableGateway due to missing “Db\StatusLib” service

I have disabled the cache.