2.6. Interop + Factories
Instead of providing a module, a bundle, a bridge or similar framework integration prooph/service-bus ships with
2.6.1. Factory-Driven Message Bus Creation
The concept behind these factories is simple but powerful. It allows us to provide you with bootstrapping logic for the message buses without the need to rely on a specific framework. However, the factories have three requirements.
- Your Inversion of Control container must implement the interop-container interface.
- interop-config must be installed
- The application configuration should be registered with the service id
configin the container.
Note: Don't worry, if your environment doesn't provide the requirements. You can always bootstrap a message bus by hand. Just look at the factories for inspiration in this case.
2.6.2. Customizing via Configuration
config folder of prooph/service-bus you will find example configuration files.
Configuration is a simple PHP array flavored with some comments to help you understand the structure.
Now follow the simple steps below to integrate prooph/service-bus in your framework and/or application.
- Merge configuration into your application config either by hand or by using the mechanism of your framework.
- Customize the configuration so that it meet your needs. The comments in the config file will tell you more.
- (Only required if not done by your framework) Make your application config available as a service in the
Inversion of Control container. Use
configas the service id (common id for application config).
- Register the message buses as services in your IoC container and use the located in
src/Containerto create the different message buses. How you can register a message bus depends on your container. Some containers like zend-servicemanager or pimple-interop allow you to map a service id to an
invokable factory. If you use such an IoC container you are lucky. In this case you can use the prooph/service-bus factories as-is. We recommend using
Prooph\ServiceBus\<CommandBus/EventBus/QueryBus::classas service id.
*Note: If you're still unsure how to do it you might have a look at the
BusFactoriesTest located in the