PHPackages                             srlabs/parley - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. srlabs/parley

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

srlabs/parley
=============

Polymorphic Messaging for Laravel

6.0.0(4y ago)145233[1 issues](https://github.com/stagerightlabs/Parley/issues)MITPHPPHP ^8.0

Since Aug 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/stagerightlabs/Parley)[ Packagist](https://packagist.org/packages/srlabs/parley)[ RSS](/packages/srlabs-parley/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelogDependencies (7)Versions (18)Used By (0)

Parley: Polymorphic Messaging for Laravel Applications
------------------------------------------------------

[](#parley-polymorphic-messaging-for-laravel-applications)

[![Build Status](https://camo.githubusercontent.com/3821097d58d8cca163548ab3e603e49ed809583d3f4e5477148da14e80496fd1/68747470733a2f2f7472617669732d63692e6f72672f53524c6162732f5061726c65792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SRLabs/Parley)

With Parley you can easily send messages between different object types within a Laravel application. These "conversations" can be bi-directional, allowing for easy communication with your users about topics relevant to your application.

- Associate threads with reference objects, such as orders or any other eloquent model instance
- Keep track of which members have or haven't "read" the messages
- Optionally mark threads as "open" or "closed"

Here is an example:

```
Parley::discuss([
    'subject' => "A New Game has been added",
    'body'   => "A new game with {$teamB->name} has been added to the schedule.",
    'alias'  => "The Commissioner",
    'author' => $admin,
    'regarding' => $game
])->withParticipant($teamA);
```

When a player logs in, their unread Parley messages can be retrieved like so:

```
$messages = Parley::gatherFor([$user, $user->team])->unread()->get();
```

If this user wants to reply to a message, it can be done like this:

```
$thread = Parley::find(1);
$thread->reply([
    'body' => 'Thanks for the heads up! We will bring snacks.',
    'author' => $user
]);
```

Additional usage examples and the API can be found [here](http://stagerightlabs.com/projects/parley).

### Installation

[](#installation)

This package can be installed using composer:

```
$ composer require srlabs/parley
```

Add the Service Provider and Alias to your `config/app.php` file:

```
'providers' => array(
    // ...
    Parley\ParleyServiceProvider::class,
    // ...
)
```

```
'aliases' => [
    // ...
    'Parley'    => Parley\Facades\Parley::class,
    // ...
],
```

Next, publish and run the migrations

```
php artisan vendor:publish --provider="Parley\ParleyServiceProvider" --tag="migrations"
php artisan migrate
```

Any Eloquent Model that implements the `Parley\Contracts\ParleyableInterface` can be used to send or receive Parley messages. To fulfill that contract, you need to have `getParleyAliasAttribute` and `getParleyIdAttribute` methods available on that model:

- `getParleyAliasAttribute()` - Specify the "display name" for the model participating in a Parley Conversation. For users this could be their username, or their first and last names combined.
- `getParleyIdAttribute()` - Specify the integer id you want to have represent this model in the Parley database tables. It is most likely that you will want to use the model's `id` attribute here, but that is not always the case.

NB: While you are required to provide an alias for each Parleyable Model, You are not required to use that alias when creating threads - you can optionally specify a different "alias" attribute when creating messages.

You are now ready to go!

### Events

[](#events)

Whenever a new thread is created, or a new reply message is added, an event is fired. You can set up your listeners in your EventServiceProvider like so:

```
protected $listen = [
    'Parley\Events\ParleyThreadCreated' => [
        'App\Listeners\FirstEventListener',
        'App\Listeners\SecondEventListener'
    ],
    'Parley\Events\ParleyMessageAdded' => [
        'App\Listeners\ThirdEventListener',
        'App\Listeners\FourthEventListener'
    ],
]
```

Each event is passed the Thread object and the author of the current message. You can retrieve these objects using the `getThread()` and `getAuthor` methods:

```
class AppEventListener
{

    /**
     * Handle the event.
     *
     * @param  SiteEvent  $event
     * @return void
     */
    public function handle(ParleyEvent $event)
    {
        // Fetch the thread
        $thread = $event->getThread();

        // Fetch the author
        $author = $event->getAuthor();

        // ...
    }
}
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 94% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~158 days

Recently: every ~269 days

Total

16

Last Release

1560d ago

Major Versions

1.0.x-dev → 2.1.02016-06-15

2.4.0 → 3.0.02019-09-04

3.0.0 → 4.0.02020-03-04

4.0.0 → 5.0.02020-09-09

5.0.0 → 6.0.02022-02-09

PHP version history (6 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=5.5.9

2.2.0PHP &gt;=7.1.3

4.0.0PHP ^7.2

5.0.0PHP ^7.3

6.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/97d8f58fda6a474519e876ece356e8246390e4e7f3b2c56ee8ec6bc1e88cfa6b?d=identicon)[Stage Right Labs](/maintainers/Stage%20Right%20Labs)

---

Top Contributors

[![rydurham](https://avatars.githubusercontent.com/u/674347?v=4)](https://github.com/rydurham "rydurham (94 commits)")[![adamdburton](https://avatars.githubusercontent.com/u/62564?v=4)](https://github.com/adamdburton "adamdburton (6 commits)")

---

Tags

laravelnotificationsmessagingpolymorphicpolymorphism

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/srlabs-parley/health.svg)

```
[![Health](https://phpackages.com/badges/srlabs-parley/health.svg)](https://phpackages.com/packages/srlabs-parley)
```

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
