Application Config

Use application config API to modify and access application configuration.

Config Interface

Note

The configuration is read-only after application is fully bootstrapped.

$app->getConfig()

Accessing application configuration.

/** @var \Zend\Config\Config $config */
$config = $app->getConfig();

Note

It is possible to set configuration values before application is fully bootstrapped.

Setting configuration value.

$app->getConfig()->myConfigKey = 'myConfigValue';

Getting configuration value.

/** @var \Zend\Config\Config|mixed $myConfig */
$myConfig = $app->getConfig('myConfigKey', $default = null);

$app->getCoreConfig()

Getting core configuration value.

/** @var \Zend\Config\Config|mixed $myCoreConfig */
$myCoreConfig = $app->getCoreConfig('myCoreConfigKey', $default = null);

Config Features

Config features are registered into the configuration like following:

Webino::config([
    new SomeConfigFeature,
]);

Available features:

Events

Use event system config features to configure listeners.

Listener

Configuring listeners.

use WebinoAppLib\Feature\Listener;

Webino::config([
    // invokable
    new Listener(MyExampleListener::class),
    // factory
    new Listener(MyExampleListener::class, MyExampleListenerFactory::class),
]);

CoreListener

Configuring core listeners.

use WebinoAppLib\Feature\CoreListener;

Webino::config([
    // invokable
    new CoreListener(MyExampleCoreListener::class),
    // factory
    new CoreListener(MyExampleCoreListener::class, MyExampleCoreListenerFactory::class),
]);

Services

Use services config features to configure invokable services and service factories.

Service

Configuring services.

use WebinoAppLib\Feature\Config;
use WebinoAppLib\Feature\Service;

Webino::config([
    // invokable
    new Service(MyService::class),
    // factory
    new Service(MyService::class, MyServiceFactory::class),
]);

CoreService

Application core service config feature.

use WebinoAppLib\Feature\CoreService;

Webino::config([
    // invokable
    new CoreService(MyCoreService::class),
    // factory
    new CoreService(MyCoreService::class, MyCoreServiceFactory::class),
]);

Logging

Use logging config features to configure logging.

Log

Configuring app file logger writer, data/log/app.log by default.

use WebinoConfigLib\Feature\Log;

Webino::config([
    // Enabling default logging
    new Log,
    // Overriding default logging file
    new Log('my/folder/app.log'),
]);

Configuring file logger formatting.

use WebinoConfigLib\Feature\Log;

Webino::config([
    // Simple format
    (new Log)->setSimpleFormat('%timestamp% %priorityName% (%priority%): %message% %extra%'),

    // XML format
    (new Log('my/folder/app.log.xml'))->setXmlFormat(),
]);
Forking Logger

Creating new logger writer instead of overriding the default.

use WebinoConfigLib\Feature\Log;

Webino::config([
    (new Log('my/folder/my-app.log'))->setName('my'),
]);

Logger

Configuring custom logger.

use WebinoConfigLib\Feature\Log;
use WebinoConfigLib\Feature\Logger;
use WebinoConfigLib\Feature\FirePhpLog;

Webino::config([
    new Logger('myLogger', [
        new Log,
        // etc.
    ]),
]);

ChromePhpLog

Configuring app ChromePHP logger writer.

use WebinoConfigLib\Feature\ChromePhpLog;

Webino::config([
    new ChromePhpLog,
]);

FirePhpLog

Configuring app FirePHP logger writer.

use WebinoConfigLib\Feature\FirePhpLog;

Webino::config([
    new FirePhpLog,
]);

Caching

Use cache config features to configure caching.

ConfigCacheEnabled

Toggling application config caching.

use WebinoConfigLib\Feature\ConfigCacheEnabled;

Webino::config([
    // enable
    new ConfigCacheEnabled,
    // disable
    new ConfigCacheEnabled(false),
]);

See also

Caching Methods

FilesystemCache

Configuring filesystem cache.

use WebinoAppLib\Feature\FilesystemCache;

Webino::config([
    new FilesystemCache,
]);

MemoryCache

Configuring in memory cache.

use WebinoAppLib\Feature\MemoryCache;

Webino::config([
    new MemoryCache,
]);

Filesystem

Use filesystem config features to configure filesystems.

DefaultFilesystem

Overriding default local working dir filesystem.

use WebinoAppLib\Feature\DefaultFilesystem;

Webino::config([
    // optional
    new DefaultFilesystem('custom/root'),
]);

See also

$app->file()

MemoryFilesystem

Configuring temporary filesystem in the memory.

use WebinoAppLib\Feature\MemoryFilesystem;

Webino::config([
    new MemoryFilesystem,
]);

Routing

Use routing config features to configure routing.

Route

Adding routes via config.

use WebinoAppLib\Feature\Config;
use WebinoConfigLib\Feature\Route;

Webino::config([
    (new Route('myRoute'))->setLiteral('/my/route/path'),
]);