Working with configuration values in concrete5 5.7+

This document requires that you have read about the Service Container.

In old 5.6 and early 5.7 days, we used static methods like Config::get(), Config::save(). The optimal code is now the following:

$config = $app->make('config');

You can also use $config = $app['config'] or $config = $app->config, but the former code is slightly faster. Once you have the $config instance, you can use all its methods directly ($config->get(), $config->save(), $config->set() $config->has(), …).

You can also work with the $config object as if it was an array:

  • $myVar = $config['seo.canonical_url'];
    is the same as
    $myVar = $config->get('concrete.version');

  • $config['seo.canonical_url'] = true;
    is the same as
    $config->set('seo.canonical_url', true);

Loading Conversation