Get site name programmatically in drupal 8 & 9

This configuration setting is easy to get with the following snippet.

\Drupal::config('system.site')->get('name');

 

 

Saved you some valuable time?

Buy me a drink 🍺 to keep me motivated to create free content like this!