Get global symfony kernel parameters

Get global symfony kernel parameters

Recently I needed to inject the current environment into a service, but couldn't remember how the parameter Symfony offers for it was named. Luckily you can output the existing parameters on the console. And it makes it easier if you remember that it was something with "kernel".

Just run the following command:

php bin/console debug:container --parameters | grep kernel

And you'll get all available parameters:

kernel.bundles                   {"FrameworkBundle":"Symfony\\Bundle\\FrameworkBundle\\Framew...
kernel.bundles_metadata          {"FrameworkBundle":{"path":"\/Users\/liplex\/Projekte\/Symfo...
kernel.cache_dir                 /Users/liplex/Projekte/Symfony/api/var/cache/dev
kernel.charset                   UTF-8
kernel.container_class           srcApp_KernelDevDebugContainer
kernel.debug                     true
kernel.default_locale            en
kernel.environment               dev
kernel.error_controller          error_controller
kernel.http_method_override      true
kernel.logs_dir                  /Users/liplex/Projekte/Symfony/api/var/log
kernel.name                      src
kernel.project_dir               /Users/liplex/Projekte/Symfony/api
kernel.root_dir                  /Users/liplex/Projekte/Symfony/api/src
kernel.secret                    %env(APP_SECRET)%
kernel.trusted_hosts             []
router.resource                  kernel::loadRoutes

 // To search for a specific parameter, re-run this command with a search term. (e.g. debug:container
 // --parameter=kernel.debug)