Download the PHP package phine/observer without Composer

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

Observer

Build Status Coverage Status Latest Stable Version Total Downloads

A PHP library that implements the observer pattern.

Summary

This library provides an implementation of the observer pattern. You can use it to create other libraries such as event managers, state machines, MVC frameworks, and even provide a plugin system for application.

Requirement

Installation

Via Composer:

$ composer require "phine/observer=~2.0"

Usage

To create a subject, you will need to either create your own implementation of SubjectInterface, or use the bundled Subject class.

Observing

You will then need to create your own implementation of ObserverInterface to observe changes made to the subject. You may use multiple instances of the observer implementation, or even the same instance multiple times.

With the example above, you can expect the following output:

First
Second
Third
Third

Prioritizing Observers

Implementations of SubjectInterface support prioritizing observers during registration (registerObserver()). By default, shown in all the examples provided, the priority is SubjectInterface::FIRST_PRIORITY (which is 0, zero). You may, however, specify your own priority:

With the above example, you can expect the following output:

E
C
D
B
A

When a subject updates its observers it begins at priority 0 (zero), and works its way to PHP_INT_MAX (the lowest possible priority). If multiple observers are registered using the same provider, they will be updated in the order that they were registered.

Interrupting an Update

When a subject is in the process of updating its registered observers, an observer may interrupt the subject. An interrupt is performed by an observer when it calls the SubjectInterface::interruptUpdate() method.

Using the following example:

You can expect the following output:

So what did the interrupting cow say?
PHP Fatal error:  Uncaught exception '[...]' with message 'MOOOOO' [...]
[...]

Observers are not required to provide a reason (instance of ReasonException), but it will definitely help during the debugging process if one is given.

Collections of Subjects

There may be occasions where you will need to manage a collection of subjects. The library provides two ways of doing so: Collection and ArrayCollection. The Collection will associate an individual subject with a specific unique identifier.

You can then retrieve the subjects or replace them as needed.

The ArrayCollection class provides a leaner way of managing subject registrations. It is an extension of the Collection class that supports array access through ArrayCollectionInterface.

Like the regular Collection class, you can also replace and retrieve individual subjects.

Documentation

You can find the API documentation here.

License

This library is available under the MIT license.


All versions of observer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.9
phine/exception 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 phine/observer contains the following files

Loading the files please wait ....