PHPackages                             fluffy/connector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. fluffy/connector

ActiveLibrary[Testing &amp; Quality](/categories/testing)

fluffy/connector
================

Provides 'Signals and slots' pattern

1.3.4(9y ago)1856GPLv3PHPPHP &gt;=5.5.0

Since Jul 6Pushed 9y ago2 watchersCompare

[ Source](https://github.com/PavelLoparev/connector)[ Packagist](https://packagist.org/packages/fluffy/connector)[ Docs](https://github.com/pavelfluffy/connector)[ RSS](/packages/fluffy-connector/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/8b001f5c04052c38a8ddecbce0078e102fa75cdb02c51149a99ca71ed8e37e2b/68747470733a2f2f7472617669732d63692e6f72672f506176656c4c6f70617265762f636f6e6e6563746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PavelLoparev/connector)

Connector - "Signals and slots" mechanism for PHP.
==================================================

[](#connector---signals-and-slots-mechanism-for-php)

This library is inspired by Qt "Signals and slots" mechanism so it's pretty similar.

Signals and slots
=================

[](#signals-and-slots)

Signal is something that tell outer world about the internal state of an object. For example: phones can ring, cats can meow etc. Rings and meows are signals. They tell us about changing in their internal states.

You can react on that signals in some way. For example: answer the call or feed the cat. Your reactions are slots.

There are tha same situations in programming: sometimes we need to react on some changes in object's state. And that's what this library for: it makes communication between objects easier. Even easier than it could be with "Observer" pattern.

Installation
============

[](#installation)

Run

```
$ composer require fluffy/connector

```

or add dependency to your composer.json file

```
"require": {
    ...
    "fluffy/connector": "^1.3"
}
```

Usage
=====

[](#usage)

### 1. Signals

[](#1-signals)

If you want your object will be able to emit signals you need to implement `SignalInterface` and use `SignalTrait`. For example you have some logger class and you want to emit signal `somethingIsLogged` when logger finished work:

```
