Installation

Installing Ecotone for Symfony, Laravel or Stand Alone

Install for Symfony

Use composer in order to download Ecotone Symfony Bundle

If you're using Symfony Flex, bundle will auto-configure. If that did not happen, register bundle in config/bundles.php

Ecotone\SymfonyBundle\EcotoneSymfonyBundle::class => ['all' => true]

Install for Laravel

Use composer in order to download Ecotone Laravel

Provider should be automatically registered. If that did not happen, register provider

'providers' => [
    \Ecotone\Laravel\EcotoneProvider::class
],

Install Ecotone Lite (No framework)

If you're using no framework or framework different than Symfony or Laravel, then you may use Ecotone Lite to bootstrap Ecotone.

In order to start, you need have to composer.json with PSR-4 or PSR-0 autoload setup.

With Custom Dependency Container

If you already have Dependency Container configured, then:

$ecotoneLite = EcotoneLite::bootstrap(
    classesToResolve: [User::class, UserRepository::class, UserService::class],
    containerOrAvailableServices: $container
);

Load namespaces

By default Ecotone will look for Attributes only in Classes provided under "classesToResolve". If we want to look for Attributes in given set of Namespaces, we can pass it to the configuration.

$ecotoneLite = EcotoneLite::bootstrap(
    classesToResolve: [User::class, UserRepository::class, UserService::class],
    containerOrAvailableServices: $container,
    configuration: ServiceConfiguration::createWithDefaults()->withNamespaces(['App'])
);

With no Dependency Container

You may actually run Ecotone without any Dependency Container. That may be useful for small applications, testing or when we want to run some small Ecotone's script.

$ecotoneLite = EcotoneLite::bootstrap(
    classesToResolve: [User::class, UserRepository::class, UserService::class],
    containerOrAvailableServices: [new UserRepository(), new UserService()]
);

Ecotone Lite Application

You may use out of the box Ecotone Lite Application, which provide you with Dependency Container.

$ecotoneLite = EcotoneLiteApplication::bootstrap();

$commandBus = $ecotoneLite->getCommandBus();
$queryBus = $ecotoneLite->getQueryBus();

With default configuration, Ecotone will look for classes inside "src" catalog.

Last updated

Was this helpful?