PHP code example of morebec / orkestra-symfony-bundle
1. Go to this page and download the library: Download morebec/orkestra-symfony-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
morebec / orkestra-symfony-bundle example snippets
class ShippingModuleConfigurator implements OrkestraModuleConfiguratorInterface
{
public function configureContainer(OrkestraConfiguration $conf): void
{
$conf->useSystemClock();
// Configure the message bus
$conf->configureMessageBus(
(new DefaultMessageBusConfiguration())
->withMiddleware(YourCustomMiddleware::class)
);
// Configure the event store
$conf->configureEventStore(
(new EventStoreConfiguration())
->usingImplementation(PostgreSqlEventStore::class)
->decoratedBy(UpcastingEventStoreDecorator::class)
->decoratedBy(MessageBusContextEventStoreDecorator::class)
->withUpcaster(YourEventUpcaster::classs)
);
// Configure Event Processing.
$conf->configureEventProcessing(
(new EventProcessingConfiguration())
->usingEventStorePositionStorageImplementation(PostgreSqlEventStorePositionStorage::class)
// Configure Projection Processing
->configureProjectionProcessing(
(new ProjectionProcessingConfiguration())
->configureProjectorGroup(
(new ProjectorGroupConfiguration())
->withName('api')
->withProjector(YourProjector::class)
)
)
);
$conf->commandHandler(ShippingMessageHandler::class)
->autoroute()
->disableMethodRoute('__invoke')
;
$conf->consoleCommand(ShippingConsoleCommand::class);
// Configure a service using Symfony's container as per usual.
$conf->service(LoggerInterface::class, YourLogger::class)->args('%env.logDir%)');
}
public function configureRoutes(RoutingConfigurator $routes): void
{
}
}
/** @var OrkestraConfiguration $configuration */
$configuration->getMessageBusConfiguration()
->withMessageHandler(YourMessageHandler::class)
;
// Alternatively using the helper methods of the OrkestraConfiguration class
// This will behind the scene find the message bus configuration and attach
// the handler to it.
$configuration
->messageHandler(YourMessageHandler::class)
;
/** @var OrkestraConfiguration $configuration */
$configuration->getMessageBusConfiguration()
->configureMessageNormalizer(
(new MessageNormalizerConfiguration())
->usingDefaultImplementation()
->withNormalizationPair(
YourNormalizer::class,
YourDenormalizer::class
)
// Or
->withNormalizer(YourNormalizer::class)
->withDenormalizer(YourDenormalizer::class)
)
;
// Alternatively using the helper methods of the OrkestraConfiguration class
// This will behind the scene find the message bus configuration and attach
// the handler to it.
$configuration
->messageHandler(YourMessageHandler::class)
;
/** @var OrkestraConfiguration $configuration */
$configuration
->configureTimeoutProcessing(
(new TimeoutProcessingConfiguration())
->usingManagerImplementation(TimeoutManager::class)
// Alternatively for the manager you can use the default implementation (TimeoutManager):
->usingDefaultManagerImplementation()
// Storage
->usingStorageImplementation(PostgreSqlTimeoutStorage::class)
);
/** @var OrkestraConfiguration $configuration */
$configuration->configureEventStore(
(new EventStoreConfiguration())
->usingImplementation(PostgreSqlEventStore::class)
// Decorators priority ordered by order of declaration.
->decoratedBy(UpcastingEventStoreDecorator::class)
->decoratedBy(MessageBusContextEventStoreDecorator::class)
// The chain is done in order of declaration.
// No need to define the UpcasterChain, it is automatically registered.
->withUpcaster(YourEventUpcaster::classs)
);
/** @var OrkestraConfiguration $configuration */
$configuration->cconfigureEventProcessing(
(new EventProcessingConfiguration())
// Position storage for Tracking Event Processors.
->usingEventStorePositionStorageImplementation(PostgreSqlEventStorePositionStorage::class)
// Configure Projection Processing
->configureProjectionProcessing(
(new ProjectionProcessingConfiguration())
->configureProjectorGroup(
(new ProjectorGroupConfiguration())
->withName('api')
->withProjector(YourProjector::class)
)
)
);
// Adding a new projector group
/** @var OrkestraConfiguration $configuration */
$configuration->getProjectionProcessingConfiguration()
->configureProjectorGroup(
(new ProjectorGroupConfiguration())
->withName('api')
->withProjector(YourProjector::class)
);