Download the PHP package aura/signal without Composer

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

Aura Signal

Build Status

The Aura Signal package is a SignalSlots/EventHandler implementation for PHP. With it, we can invoke handlers ("slots" or "hooks") whenever an object sends a signal ("notification" or "event") to the signal manager.

This package is compliant with PSR-0, PSR-1, and PSR-2. If you notice compliance oversights, please send a patch via pull request.

Basic Usage

Instantiating the Signal Manager

First, instantiate the signal Manager class. The easiest way to do this is to call the Aura.Signal/scripts/instance.php script.

Adding Signal Handlers

Before we can send a signal to the Manager, we will need to add a handler for it. To add a handler, specify:

  1. The class expected to be sending the signal. This can be '*' for "any class", or a fully-qualified class name.

  2. The name of the signal.

  3. A closure or callback to handle the signal.

For example, to add a closure that will be executed every time an object of the class Vendor\Package\Example sends a signal called 'example_signal':

Signals By Class


To send a signal, the sending class must have an instance of the Manager. The class should call the send() method with the originating object (itself), the signal being sent, and arguments to pass to the signal handler.

For example, we will define the Vendor\Package\Example class, and have it send a signal to the Manager.

Now whenever we call the doSomething() method, it will send the 'example_signal' to the Manager, and the Manager will invoke the handler for that signal.

Signal Inheritance

If a class sends a signal, and no handler has been set for it, then the Manager will do nothing. However, if a handler has been set for a parent class, and one of its child classes sends a signal handled for the parent, the Manager will handle that signal for the child as well.

For example, if we have these two classes, and call doSomethingElse() on each of them ...

... then the Manager will handle the signal from ExampleChild because its parent has a handler for it. The Manager will not handle the signal for ExampleOther because no handlers for it or its parents have been added to the Manager.

Signals By Object

It is possible to tie a handler to an object instance, so that only signals sent from that specific object will be handled. To do so, pass the object instance as the $sender for the handler.

If that specific object instance sends the example_signal then the handler will be triggered, but no other instance of ExampleChild will trigger the handler when it sends the same signal. This is useful for setting signal handlers from within an object that contains its own callback; for example:

When ExampleAnotherChild::action() is called, the code:

  1. Sends a 'preAction' signal to the Manager, which in turn calls the preAction() method on the object

  2. Calls the doSomething() method on the object (n.b., remember that the doSomething() method sends an 'example_signal' of its own to the Manager)

  3. Sends a 'postAction' signal to the Manager, which in turn calls the postAction() method on the object.

If there are class-based handlers for ExampleAnotherChild class or its parents, those will also be executed. This means we can set up combinations of handlers to be applied to classes overall, along with handlers that are tied to specific objects.

Advanced Usage

Handler Position Groups

By default, all Handler objects will be appended to the Manager stack, and will be processed the order they were added. Sometimes you will need a Handler to be processed in a different order; for example, before or after all others. If so, you can pass a $position value when adding a Handler to the Manager. (The default $position for Handler objects is 5000.)

Handler objects added at a position will still be appended within that position group.

Result Inspection

After a signal has been sent, we can review the results returned by every handler for that signal.

The getResults() method returns a ResultCollection of Result objects, each of which has these properties:

If you need only the last result, you can call getLast() on the ResultCollection object.

Stopping Signal Processing

Sometimes it will be necessary to stop processing signal handlers. If a handler callback returns the Aura\Signal\Manager::STOP constant, then no more handlers for that signal will be processed.

First we define the handlers; note that the second one returns the STOP constant:

Then, from inside an object, we send a signal:

Normally, $results would have three entries. In this case it has only two, because the second handler returned \aura\signal\Manager::STOP. As such, the third handler was never executed. You can call ResultCollection::isStopped() to see if the Manager stopped processing handlers in this way.

Setting Handlers at Construction

It is possible to set the Handler definitions for a Manager at construction time. This allows us to use one or more config files to define the Handler stack for a Manager.

Given this file at /path/to/signal_handlers.php ...

... we can configure a Manager like so:

That is the equivalent of calling $signal->handler() three times to add each handler.

Thanks

Thanks to Richard "Cyberlot" Thomas for the original suggestion, Galactic Void for bringing it back up, and Matthew Weier O'Phinney.


All versions of signal with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
aura/installer-default Version 1.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 aura/signal contains the following files

Loading the files please wait ....