New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

srlabs/parley

Polymorphic Messaging for Laravel
523 14

Larablocks Analysis

srlabs/parley works with Laravel 9 (latest release 6.0.0, Feb 9, 2022), which reached end of life on Feb 6, 2024: no more fixes, even for security.

Laravel 4 to 8 in earlier releases.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 9, past end of life since Feb 6, 2024
  • No release in the last 12 months (last: Feb 9, 2022)
  • 0 downloads a month (needs 10,000)
  • 14 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Feb 9, 2022.
  • No releases in the last 12 months.
  • First released: Aug 11, 2015.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.

Install
composer require srlabs/parley
Latest Version:6.0.0
PHP:^8.0
Laravel:9
Older releases:4 – 8
License:MIT
Last Updated:Feb 9, 2022
Links: GitHub  ·  Packagist
Maintainer: Stage Right Labs

Parley: Polymorphic Messaging for Laravel Applications

Build Status

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.

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

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();

        // ...
    }
}

Alternatives to srlabs/parley

offload-project/laravel-invite-only

A Laravel package for managing user invitations with polymorphic relationships,...

22,586 74
nugsoft/signalbridge-laravel-sdk

Laravel SDK for SignalBridge SMS Gateway - Send SMS messages through multiple ve...

1,452 1
realrashid/laravel-zoho-cliq

A Laravel package for integrating with Zoho Cliq, allowing you to send messages,...

3,977 4

Version History

Version Released PHP Laravel License
6.0.0 ^8.0 ^9.0 MIT
5.0.0 ^7.3 ^8.0 MIT
4.0.0 ^7.2 ^7.0 MIT
3.0.0 >=7.1.3 ^6.0 MIT
2.4.0 >=7.1.3 5.8.* MIT