I knew that question was coming, so it's fine.
So. Before I begin, I need to correct something from a previous reply, in case people understand it the wrong way. Storing sensitive API credentials should be done in the .env file, and not in the config file directly.
And also, I'm not an expert on this either, so to anyone who is reading this, feel free to correct me if I make a mistake.
So for example, don't do the following:
return [
'secret' => 'sakljdaskldjaslkdjasljdasjdl13132'
];
You should instead do:
return [
'secret' => env('SOME_SECRET_KEY', '')
];
This way, API credentials aren't pushed to source control, since we ignore .env files. And since we only ever want to cache the config files in production, we don't need to worry about that cached config file being exposed due to a commit you made.
Now, if the web server is compromised, then it's game over really. They could potentially have access to everything.
If only the database is compromised for some reason, then only the data within that database is compromised. Or what if you accidentally spat out sensitive data in a view? That would be a vulnerability. Or, perhaps you have a settings page that lists out all settings from the database table, which also happens to have sensitive data; and only admins are allowed access to that page, but then you have a "corrupt" admin or someone gains access to your account etc.
Take a look at these resources. The first is about best practices for databases. The second covers various topics within PHP, including a security section.
https://www.esecurityplanet.com/network-security/6-database-security-best-practices.html
https://phptherightway.com/