Cannot Access Config Values from app.php

Permalink
Hi There,

I am trying to access configuration values from app.php / concrete.php config files from within my theme header partial or from a block view. I have read the documentation about

https://documentation.concrete5.org/developers/appendix/concrete5-ve...

and

https://documentation.concrete5.org/developers/appendix/concrete5-ve...

My application/config/app.php looks like this:

return array(
   'is-prod' => false,
   'date' => array(
      'format' => 'd.m.Y',
   ),
);


In my block view, I am trying to access the config like this:

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$config = $app->make('config');
$dateFormat = $config['date.format'];


but $dateFormat is always an empty string. I also tried to access other config values which are defined by concrete5 itself, but I also cannot access them.

Am I doing something wrong?

Best
Jan

janwidmer
 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Try your date format as 'd m Y' (without the dots)
Or 'd/m/Y'
janwidmer replied on at Permalink Reply
janwidmer
Hey..

The problem is not the date string itself, but generally accessing config values.. I tried to access different config values but I always get an empty string back.
janwidmer replied on at Permalink Best Answer Reply
janwidmer
Solved:

If anybody has the same problem, my "mistake" was to not specifying the config namespace.
The config namespace implicitly gets defined by the filename of the config file.

E.g. if you have the config file /application/config/app.php, the config namespace is "app". You can access config values from this file like this:

$dateFormat = $config->get('app.date.format');