Download the PHP package icanboogie/event without Composer

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

Event

Release Code Quality Code Coverage Downloads

The icanboogie/event allows you to provide hooks which other developers can attach to, to be notified when certain events occur inside the application and take action.

Inside ICanBoogie, events are often used to alter initial parameters, take action before/after an operation is processed or when it fails, take action before/after a request is dispatched or to rescue an exception.

Installation

Feature highlights

A twist on the Observer pattern

The pattern used by the API is similar to the Observer pattern, although instead of attaching event hooks to objects they are attached to their class. When an event is fired upon a target object, the hierarchy of its class is used to filter event hooks.

Consider the following class hierarchy:

ICanBoogie\Operation
└─ ICanBoogie\Module\Operation\SaveOperation
    └─ Icybee\Modules\Node\Operation\SaveOperation
        └─ Icybee\Modules\Content\Operation\SaveOperation
            └─ Icybee\Modules\News\Operation\SaveOperation

When a ProcessEvent is emitted with a …\News\Operation\SaveOperation instance, all event hooks attached to the classes for this event are called, starting from the event hooks attached to the instance class (…\News\Operation\SaveOperation) all the way up to those attached to its root class.

Thus, event hooks attached to the …\Node\Operation\SaveOperation class are called when a ProcessEvent event is fired with …\News\Operation\SaveOperation instance. One could consider that event hooks are inherited.

Getting started

To be emitted, events need an event collection, which holds event hooks. Because a new event collection is created for you when required, you don't need to set one up yourself. Still, you might want to do so if you have a bunch of event hooks that you need to attach while creating the event collection. To do so, you need to define a provider that returns your event collection when required.

The following example demonstrates how to set up a provider that instantiates an event collection with event hooks provided by an app configuration:

Typed events

Events are subclasses of the Event class.

The following code demonstrates how a ProcessEvent class may be defined:

Event types

If an event has a target, the event is obtained using the for() method and the target class or object. If an event doesn't have a target, the event type is the event class.

Namespacing and naming

Event classes should be defined in a namespace unique to their target object. Events targeting ICanBoogie\Operation instances should be defined in the ICanBoogie\Operation namespace.

Firing events

Events are fired with the emit() function.

Attaching event hooks

Event hooks are attached using the attach() method of an event collection. The attach() method is smart enough to create the event type from the parameter types. This works with any callable: closure, invokable objects, static class methods, functions.

The following example demonstrates how a closure may be attached to a BeforeProcessEvent event.

The following example demonstrates how an invokable object may be attached to that same event type.

Attaching an event hook to a specific target

Using the attach_to() method, an event hook can be attached to a specific target, and is only invoked for that target.

Attaching a one-time event hook

The once() method attaches an event hook that is automatically detached after it's been used.

Attaching event hooks using the events config

When the package is bound to ICanBoogie by icanboogie/bind-event, event hooks may be attached from the events config. Have a look at the icanboogie/bind-event package for further details.

Attaching event hooks to the finish chain

The finish chain is executed after the event chain was traversed without being stopped.

The following example demonstrates how an event hook may be attached to the finish chain of the count event to obtain the string "0123". If the third event hook was defined like the others we would obtain "0312".

Breaking an event hook chain

The processing of an event hook chain can be broken by an event hook using the stop() method:

Profiling events

The EventProfiler class is used to collect timing information about unused events and event hook calls. All time information is measured in floating microtime.

Helpers


Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Contributing

Please see CONTRIBUTING for details.

License

icanboogie/event is released under the BSD-3-Clause.


All versions of event with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
icanboogie/accessor Version ^2.0|^3.0|^4.0
icanboogie/inflector Version ^1.3|^2.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 icanboogie/event contains the following files

Loading the files please wait ....