Download the PHP package spatie/laravel-eventsauce without Composer

On this page you can find all versions of the php package spatie/laravel-eventsauce. 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-eventsauce

Use EventSauce in Laravel apps

Latest Version on Packagist Tests Total Downloads

EventSauce is an easy way to introduce event sourcing into PHP projects. This package allows EventSauce to make use of Laravel's migrations, models and jobs. It can also help with generating code for commands and events. If you want to use EventSauce in a Laravel app, this package is the way to go!

Before using laravel-eventsauce you should already know how to work with EventSauce.

Here's a quick example of how to create a new aggregate root and matching repository. Let's run this command:

The App\MyDomain\MyAggregateRoot and App\MyDomain\MyAggregateRootRepository classes will have been created. A migration to create my_aggregate_root_domain_messages will have been added to your application too. This is how MyAggregateRootRepository looks like:

You can put classnames of consumers in the $consumers array. Consumers in the $queuedConsumers array will called and be passed their messages using a queued job.

The MyAggregateRootRepository can be injected and used in any class. In this example we assume you've manually created a performMySpecialCommand method on MyAggregateRoot:

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

Next you must publish the eventsauce config file.

This is the contents of the file that will be publish to config/eventsauce.php:

Usage

Generating an aggregate root and repository

An aggregate root and matching repository can be generated used this command

This command will create App\MyDomain\MyAggregateRoot and App\MyDomain\MyAggregateRootRepository.

This is how MyAggregateRootRepository looks like:

If you repository doesn't need consumers or queued consumers, you can safely remove those variables. The only required variable is $aggregateRoot.

Of course you can also manually create an aggregate root repository. Just create a class, let it extendSpatie\LaravelEventSauce\AggregateRootRepository. Next, put the fully qualified classname of your aggregate root in a protected $aggregateRoot property. Finally add a $tableName property containing the name of the table where you want to store domain messages.

Configuring the aggregate root repository

Specifying the aggregate root

The $aggregateRoot property should contain the fully qualied class name of an aggregate root. A valid aggregate root is any class that implements EventSauce\EventSourcing\AggregateRoot

Adding consumers

Consumers are classes that receive all events and do something with them, for example creation a projection. The $consumers property should be an array that contains class names of consumers. A valid consumer is any class that implements EventSauce\EventSourcing\Consumer.

Adding queued consumers

Unless you need the result of a consumer in the same request as your command or event is fired, it's recommanded to let a consumer to perform it's work on a queue. The $queuedConsumers property should be an array that contains class names of consumers. A valid consumer is any class that implements EventSauce\EventSourcing\Consumer.

If there are any message that needs to be sent to any of these consumers, the package will dispatch a Spatie\LaravelEventSauce\QueuedMessageJob by default.

Customizing the job that passes messages to queued consumers

By default Spatie\LaravelEventSauce\QueuedMessageJob is used to pass messages to queued consumers. You can customized this job by setting the queued_message_job entry in the eventsauce config file to the class of your custom job. A valid job is any class that extends Spatie\LaravelEventSauce\QueuedMessageJob.

Changing the queued_message_job entry will change the default job of all aggregate root repositories. If you want to change the job class for a specific repository add a $queuedMessageJob property to that repository.

Here is an example:

You can use that custom job to add properties to control the timeout, max attempts and the queue to be used. You can read more on how to configure a job in the Laravel docs on queueing.

Here's an example of a custom job.

Customizing the table name where messages are stored

The $tableName property on your aggregate root repository determines where messages are being stored. You can change this to any name you want as long as you've created a a table with that name that has the following columns:

Specifying a connection

Laravel has support for multiple database connections. By default the aggregate root will use Laravel's default connection. If you want all your aggregate roots to use a the same alternative connection then specify that connection name in the connection property of the eventsauce config file.

If you want let a specific repository use an alternative connection, you can just specify it's name in the $connection property

Code generation

We can generate types, events and commands from you starting from a yaml file. You can read more on the contents of the yaml file and the generated output in the "Defining command and events using Yaml" section of the EventSauce docs.

To generate code, fill in the keys in the code_generation parts of the eventsauce config file and execute this command.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

The initial version of this package was based upon a development version of LaravelEventSauce.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-eventsauce with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^7.4
ext-json Version *
eventsauce/eventsauce Version ^0.8
illuminate/bus Version ^7.0|^8.0
illuminate/container Version ^7.0|^8.0
illuminate/queue Version ^7.0|^8.0
illuminate/support Version ^7.0|^8.0
ramsey/uuid Version ^4.0
spatie/temporary-directory Version ^1.2
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 spatie/laravel-eventsauce contains the following files

Loading the files please wait ....