Service (Application) Configuration

Ecotone Framework customization

Ecotone allows for customization of the core functionality as well as the modules.

Extension Objects

Extension objects are configuration classes that tell Ecotone which provider we want to use. For example, when setting up asynchronous processing, we can choose different Message Channel implementations like RabbitMQ, Redis, or a database queue.

class MyConfiguration
{
    #[ServiceContext]
    public function messageChannel()
    {
        return DbalBackedMessageChannelBuilder::create('async');
    }
}

Module Configuration Extensions

Module Extensions are configurations for specific module, using class based configuration. Let's take a look on Dbal module configuration as example:

class MyConfiguration // 1
{
    #[ServiceContext] // 2
    public function configuration() // 3
    {
        return DbalConfiguration::createWithDefaults() // 4
                ->withTransactionOnAsynchronousEndpoints(true)
                ->withTransactionOnCommandBus(true);
    }
}
  1. Create your own class. You can name it whatever you like.

  2. Add attribute to let Ecotone know that it should call this method to get the configuration.

  3. Name the method whatever you like. You may return array of configurations or specific configuration instance.

  4. Return specific configuration.

Ecotone does not require specific class name or method name. All what is needed is #[ServiceContext] attribute.

Environment Specific Configuration

If you want to enable different configuration for specific environment you may use of Environment attribute.

Above will turn off transactions for test environment, keeping it however for prod and dev.

Configuration Variables

You may access your configuration variables inside ServiceContext methods.

If you don't pass ConfigurationVariable attribute, it will be taken from parameter name. Below example is equal to above.

Global Configuration

Some configuration are globally available, in that sense, they can be configured directly in related framework:

Last updated

Was this helpful?