Download the PHP package nwidart/laravel-broadway without Composer

On this page you can find all versions of the php package nwidart/laravel-broadway. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-broadway

Laravel Broadway

SensioLabsInsight Scrutinizer Code Quality Latest Stable Version Total Downloads License

Laravel Broadway is an adapter for the Broadway package.

It binds all needed interfaces for Broadway.

For reference, I've built a demo laravel application that uses this package and some event sourcing techniques.

Laravel 5 compatible package

Laravel version Package version
~4.2 ~0.2
~5.0 ~0.3
~5.1+ ~2.0

Installation

Install via composer

Service Providers

Laravel 5.5 (Auto discovery)

If you are using Laravel 5.5, this package provides auto discovery, meaning you can start coding – the Global Service Provider is already added. In case you need just some Service Providers, please add the following section to your applications composer.json:

Laravel 5.4

To finish the installation you need to add the service providers.

You have a choice here, you can either use the main Service Provider which will load the following:

Or choose to use only the Service providers you need. Don't know what you need ? Use the Global Service Provider provided.

Global Service Provider

Separate Service Providers

(Optional) Publish configuration file and migration

This will publish a config/broadway.php file and a database/migrations/create_event_store_table.php file.

(Optional) Run migration

Last step, run the migration that was published in the last step to create the event_store table.

If you haven't published the vendor files, you can use the command explained below:

Configuration

Event Store

To create the event store you can call the following command:

In the configuration file, you can choose which driver to use as an event store and which connection to use.

Once done, you can bind your EventStoreRepositories in a Service Provider like so:

For an in memory Event Store, all you need to do is change the driver in the configuration file and probably add a new event store repository implementation with an adequate name.

Read Model

To set a read model in your application you first need to set the wanted read model in the package configuration.

Once that's done you can bind your ReadModelRepositories in a Service Provider like so:

For an In Memory read model as an example:

See the demo laravel application and specifically the Service Provider for a working example.

Registering subscribers

Command handlers

To let broadway know which handlers are available you need to bind in the Laravel IoC container a key named broadway.command-subscribers as a singleton.

It's important to know Command Handlers classes in broadway need to get a Event Store repository injected.

Now just pass either an array of command handlers to the laravelbroadway.command.registry key out the IoC Container or just one class, like so:

Event subscribers

This is pretty much the same as the command handlers, except that the event subscriber (or listener) needs an Read Model repository.

Example:

Metadata Enricher

Broadways event store table comes with a field called "metadata". Here we can store all kind of stuff which should be saved together with the particular event, but which is does not fit to the domain aka the payload.

For example you like to store the ID of the current logged-in user or the IP or ...

Broadway uses Decorators to manipulate the event stream. A decorator consumes one or more Enrichers, which provide the actual data (user ID, IP). Right before saving the event to the stream, the decorator will loop through the registered enrichers and apply the data.

The following example assumes you added the global ServiceProvider of this package or at least the Nwidart\LaravelBroadway\Broadway\MetadataEnricherServiceProvider.

First we create the enricher. In this example lets assume we are interested in the logged-in user. The enricher will add the user ID to the metadata and returns the modified metadata object. However, in some cases – like in Unit Tests - there is no logged-in user available. To tackle this, the user ID can injected via constructor.

Second you need to register the Enricher to the decorator and pass the decorator to your repository

To retrieve the metadata you need to pass the DomainMessage as the 2nd parameter to an apply*-method in your projector.

All the rest are conventions from the Broadway package.


Changelog

License (MIT)


All versions of laravel-broadway with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5.9
doctrine/dbal Version ~2.5
broadway/broadway Version ~1.0.0
broadway/event-store-dbal Version ^0.1.2
illuminate/support Version 5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.7.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nwidart/laravel-broadway contains the following files

Loading the files please wait ....