Links

Service (Application) Configuration

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

Ecotone Core Configuration

Depending on the provider you choose, you can follow configuration in specific menu

Module Extensions

Module Extensions are configurations for specific module. It's class based configuration. Let's take a look on Dbal module configuration as example:
class MyConfiguration // 1
{
#[ServiceContext] // 2
public function registerTransactions() // 3
{
return DbalConfiguration::createWithDefaults() // 4
->withTransactionOnAsynchronousEndpoints(true)
->withTransactionOnCommandBus(true);
}
}
  1. 1.
    Create your own class. You can name it whatever you like.
  2. 2.
    Add attribute to let Ecotone know that it should call this method to get the configuration.
  3. 3.
    Name the method whatever you like. You may return array of configurations or specific configuration instance.
  4. 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.
class MyConfiguration
{
#[ServiceContext]
#[Environment(["dev", "prod"])]
public function registerTransactions()
{
return DbalConfiguration::createWithDefaults()
->withTransactionOnAsynchronousEndpoints(true)
->withTransactionOnCommandBus(true);
}
#[ServiceContext]
#[Environment(["test"])]
public function registerTransactions()
{
return DbalConfiguration::createWithDefaults()
->withTransactionOnAsynchronousEndpoints(false)
->withTransactionOnCommandBus(false);
}
}
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.
class MyConfiguration
{
#[ServiceContext]
public function registerTransactions(#[ConfigurationVariable("database")] string $connectionDsn)
{
return Repository($connectionDsn);
}
}
If you don't pass ConfigurationVariable attribute, it will be taken from parameter name. Below example is equal to above.
class MyConfiguration
{
#[ServiceContext]
public function registerTransactions(string $database)
{
return Repository($database);
}
}