Download the PHP package jalle19/laravel-deferred-event-dispatcher without Composer

On this page you can find all versions of the php package jalle19/laravel-deferred-event-dispatcher. 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-deferred-event-dispatcher

laravel-deferred-event-dispatcher

Build Status Coverage Status

A deferring event dispatcher for the Laravel and Lumen frameworks.

Motivation

Events are a powerful feature of any framework. It allows you to decouple your code so that the logic that triggers an event doesn't have to know what should happen in reaction to that event.

While the default implementation in Laravel/Lumen is perfectly adequate in many cases, it is fairly naive, which can lead to subpar performance. Consider the following scenario:

  1. You have your own EventServiceProvider where you have registered a bunch of event subscribers.
  2. You register this service provider in your bootstrap file

Under the hood, whenever an EventServiceProvider is registered, the EventDispatcher will also be constructed. The event dispatcher in turn will go through all the event handlers you've defined and construct each of them so that it knows which listeners to trigger in the case of an event.

While this doesn't sound that bad, it means that even for the simplest of requests (e.g. a route that only prints "OK", e.g. a health check route) will cause all your event subscribers to be constructed, which can pull in a lot of code that you don't need to fulfill the request (e.g. Doctrine and other "heavy" services").

This wouldn't be so bad if it weren't for the fact that the majority of your requests probably won't be triggering any events, so constructing and registering all your event handlers is pointless. This event dispatcher implementation aims to solve that problem.

Deferring the resolving of listeners and subscribers

A simple yet fairly effective solution is to defer the resolving of event handlers until an event is actually dispatched. This assures we don't do any unnecessary work in requests that don't trigger any events. But there's a problem...

A lot of services use events under the hood:

Even if we deferr the resolving of event handlers until an event is dispatched, chances are there is at least one event dispatched on every request anyway, defeating the whole point.

Deferring specific events

Chances are you don't care about whether a cache operation resulted in a hit or a miss, or whether a service provider has been booted or not. Ignoring these events would defer the resolving of event handlers even further, possibly for the duration of the request, which finally means we've accomplished our goal of not constructing all event handlers needlessly.

Requirements

Usage

  1. Install the library using Composer:

  2. Swap the default event dispatcher for this one:

In this example we've decided to defer resolving of event handlers whenever a cache event is dispatched.

  1. Make sure your event service provider is registered somewhere after these lines

That's it, your event handlers will now be resolved only when an event that you haven't explicitly deferred is dispatched!

License

MIT


All versions of laravel-deferred-event-dispatcher with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
illuminate/contracts Version ^5.4|^6.0
illuminate/events Version ^5.4|^6.0
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 jalle19/laravel-deferred-event-dispatcher contains the following files

Loading the files please wait ....