Download the PHP package studioignis/evt without Composer

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

Build Status Packagist Version Packagist Downloads Packagist License

StudioIgnis Evt

Easily implement domain events in your project.

Originally inspired by laracasts/commander

Installation

Install through composer by adding the package to your composer.json

Or using the command:

Usage

It is really simple, you just need the event dispatcher instance then you can start adding listeners to it:

After that you can start dispatching events:

You can dispatch multiple events at once, that's why dispatch() needs an array of events.

Events

The events are simple DTOs (data transfer objects), but should conform to the StudioIgnis\Evt\Event contract. This contract states only one method: getEventName() that is used to get the name of the event to know which listeners to run.

A trait is provided that fulfills this contract with a simple default strategy. If yout event is Acme\Events\UserWasRegistered, the trait's getEventName() will use the event class short name as the event name, that is UserWasRegistered.

Here's an example:

If we weren't using the EventName trait, we would have had to add the getEventName() method returning the event name. You don't have to use the trait, it is just a convenience, you may need to provide a custom name, in that case you wouldn't use it.

Listeners

An event listener is a class that should conform to the EventListener contract. This contract defines only one method: handle(Event $event) that expects the dispatched event.

I know, I know, everybody uses the same example, forgive my lack of originality :D

Resolving listeners upon dispatch

Instead of passing an instantiated listener, you can pass a string abstraction:

This way the listener will be instantiated when events are dispatched.

But in order to achieve this, the dispatcher must be created with an app container:

The container must conform to the \StudioIgnis\Evt\Support\Container contract.

A default container is provided for Laravel applications, so this is done automatically when a dispatcher is resolved out of the IoC container.

Raising events from your entities

You'll most likely be raising events from your entities. For this purpose you have the convenient HasDomainEvents trait.

This trait adds two methods, raise(Event $event) and releaseEvents(). raise(Event $event), as the name states, adds events pending to be dispatched. releaseEvents() returns the raised events and clear the pending events.

Let's see an example:

Now (maybe inside a command handler class) you can do this:

Laravel Integration

A service provider for the Laravel framework is included in this package. You'll need to add it to your config/app.php file:

This way, you can inject it as a dependency and will be automatically resolved out of the IoC container:

The main benefit, already stated before, is that the container will be passed to the dispatcher, allowing you to pass abstracts as your listeners to be resolved from the container.

Replacing the dispatcher

If for some reason you need to use your own custom dispatcher, you can change it in the config. To do this you would need to publish the config for this package:

And change the 'dispatcher' key to point to your dispatcher class.

License

Copyright (c) 2014 Luciano Longo

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


All versions of evt with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
illuminate/support Version ~4.1
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 studioignis/evt contains the following files

Loading the files please wait ....