PHPackages                             tfhinc/ci-newton - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tfhinc/ci-newton

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tfhinc/ci-newton
================

Simply Observe - Newton allows you to Subscribe and Listen for Event Broadcasts in the Codeigniter framework.

v2.1.0(7y ago)316MITPHPPHP &gt;=7.1.0

Since Aug 24Pushed 7y ago1 watchersCompare

[ Source](https://github.com/TFHInc/ci-newton)[ Packagist](https://packagist.org/packages/tfhinc/ci-newton)[ Docs](https://github.com/TFHInc/ci-newton)[ RSS](/packages/tfhinc-ci-newton/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

Newton
======

[](#newton)

[![Latest Version on Packagist](https://camo.githubusercontent.com/34bd9efd07d90fd591f7cc6ba818e691796b62c26b6a5dd249a728b91bcffab2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746668696e632f63692d6e6577746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tfhinc/ci-newton)[![PHP Version](https://camo.githubusercontent.com/45ed9a2f8c7d7cb7f83d44cdee7c5ffa97fe53279dd9f18fa3b4fbe3a986d692/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746668696e632f63692d6e6577746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tfhinc/ci-newton)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/c1fcd91a34d827e44a296f13ff77e616f1af09e7d6e36c86972e52d0ce9ec1b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746668696e632f63692d6e6577746f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tfhinc/ci-newton)

Simply Observe - Newton allows you to Subscribe and Listen for Event Broadcasts in the [Codeigniter](https://codeigniter.com/) framework.

Installation
------------

[](#installation)

```
composer require tfhinc/ci-newton
```

Run the post install `publish-files` command to publish the config, helper and library class files to the appropriate CI directories:

```
composer --working-dir=vendor/tfhinc/ci-newton/ run-script publish-files
```

Loading the Library
-------------------

[](#loading-the-library)

There are a few available options for loading the Newton library:

### Using the `newton()` helper function

[](#using-the-newton-helper-function)

The Newton helper function will resolve the Newton class via the CI instance. It will either load the class or return the existing class instance:

```
$this->load->helper('newton');
```

### Using the Newton Class

[](#using-the-newton-class)

The Newton class can be instantiated via namespace:

```
$newton = new TFHInc/Newton/Newton();
```

### Using the Newton CI Library

[](#using-the-newton-ci-library)

The Newton class can be loaded like any other CI library:

```
$this->load->library('Newton');
```

Class Structure
---------------

[](#class-structure)

The Newton library allows for `Listener` classes to subscribe to `Event` class broadcasts. This helps decouple your business logic into single purpose `Listener` classes that can be invoked en masse by the broadcast of an `Event`.

### Event Classes

[](#event-classes)

The `Event` class defines the properties that a given event will require and receive where there is a broadcast. The `Event` class does not contain any business logic - think of it as a blueprint of required data for a given event.

*application/events/UserCreatedEvent.php*

```
