PHPackages                             omarabdulwahhab/laramessenger - 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. omarabdulwahhab/laramessenger

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

omarabdulwahhab/laramessenger
=============================

A simple package for you to implement a chat in your application without effort !

v1.1.0.x-dev(1y ago)9281MITPHP

Since Sep 6Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/OmarAbdelwahhab30/Package.LaraMessenger)[ Packagist](https://packagist.org/packages/omarabdulwahhab/laramessenger)[ RSS](/packages/omarabdulwahhab-laramessenger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

Lara-Messenger
==============

[](#lara-messenger)

[![MarkDown](https://camo.githubusercontent.com/86bba89bca5759530cab8945d82a3c1fa4873395282db301f7c85527dbf80c1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616465253230776974682d4d61726b646f776e2d3166343235662e737667)](https://camo.githubusercontent.com/86bba89bca5759530cab8945d82a3c1fa4873395282db301f7c85527dbf80c1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616465253230776974682d4d61726b646f776e2d3166343235662e737667)[![Laravel](https://camo.githubusercontent.com/5a580364ff3bd338370177402c5c050ff81a1933927e1e475c920c90850b38a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/5a580364ff3bd338370177402c5c050ff81a1933927e1e475c920c90850b38a3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d4646324432303f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c266c6f676f436f6c6f723d7768697465)[![ask me](https://camo.githubusercontent.com/f58000eb7d904f735fbbca30835a588c716bdde0781156f1fb2e601d44307a3a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41736b2532306d652d616e797468696e672d3161626339632e737667)](https://camo.githubusercontent.com/f58000eb7d904f735fbbca30835a588c716bdde0781156f1fb2e601d44307a3a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f41736b2532306d652d616e797468696e672d3161626339632e737667)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

> A simple package for you to implement a chat in your application without effort !

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

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

[](#installation)

LaraMessenger is a Laravel package that provides messaging functionality for your Laravel application. Follow these steps to get started:

Step 1: Install the Package
---------------------------

[](#step-1-install-the-package)

You can install LaraMessenger using Composer. Open your terminal and run the following command:

```
composer require omarabdulwahhab/laramessenger

```

Step 2: Publish Configuration
-----------------------------

[](#step-2-publish-configuration)

To publish the LaraMessenger configuration and assets, use the following Artisan command:

```
php artisan vendor:publish --provider="Omarabdulwahhab\Laramessenger\ServiceProviders\LaraServiceProvider"

```

This command will copy the necessary configuration files to your project, allowing you to customize the package behavior.

Step 3: Run Migrations
----------------------

[](#step-3-run-migrations)

Next, you need to run the migrations to create the necessary database tables for LaraMessenger:

• If you didn't migrate your migrations yet :

```
php artisan migrate

```

• Then :

```
php artisan migrate --path=/database/migrations/LaraMessengerTables

```

```
php artisan migrate --path=/database/migrations/LaraMessengerForeignKeys

```

That's it! You've successfully installed LaraMessenger and set up the necessary database tables for messaging in your Laravel application.

Usage
-----

[](#usage)

Firstly : Sending The Message
=============================

[](#firstly--sending-the-message)

Here you will find how to use this simple package , follow me: • The code to send a message is very simple :

```
  $config = LaraMessenger::builder()
            ->setSenderID($request->sender_id)
            ->setReceiverID($request->receiver_id)
            ->setMessageType($request->type) // Make sure to set a type to one of them ['file','text','voice']
            ->setMessage($request->message)
  // or     ->setMessage($request->file('file'))
  // or     ->setMessage($request->file('voice'))
            ->build();
        /*HERE YOU HAVE TO OPTIONS*/
        // 1- $config->broadcast();
        // OR
        // 2- $config->send();

```

Option 1: Send a message with broadcasting (pusher) then save the message in the database.
------------------------------------------------------------------------------------------

[](#option-1-send-a-message-with-broadcasting-pusher-then-save-the-message-in-the-database)

You can use broadcasting with pusher in the package but make sure to integrate with pusher , [read this doc section](https://laravel.com/docs/10.x/broadcasting#pusher-channels)

```
  $config->broadcast()

```

Option 2: Send a message without broadcasting (just save the message in the database.)
--------------------------------------------------------------------------------------

[](#option-2-send-a-message-without-broadcasting-just-save-the-message-in-the-database)

```
$config->send()

```

### notes

[](#notes)

> ***-&gt;setMessageType($request-&gt;type) // Make sure to set a type to one of them \['file','text','voice'\] otherwise it will not work!***

> ***Now , In the updated version of the package $config-&gt;send() and $config-&gt;broadcast() return the recently stored message.***

That's it! You've successfully send a message in LaraMessenger .

Secondly : Loading The Chat ...
===============================

[](#secondly--loading-the-chat-)

Option 1: Load the chat by chatID
---------------------------------

[](#option-1-load-the-chat-by-chatid)

### V1.0.0

[](#v100)

```
  return ChatLoader::LoadChatByChatID($ChatID);

```

### V1.1.0

[](#v110)

```
  $sort = 'desc' // or 'asc'
  return ChatLoader::LoadChatByChatID($ChatID,$sort);

```

### notes

[](#notes-1)

> ***Now , In the updated version of the package You can now specify the order of retrieved messages. If you want them from oldest to newest, set the $sort variable to 'ASC'or 'asc', the opposite is true for 'DESC' or 'desc'***

> ***The default of $sort is 'DESC'.***

Option 2: Load the chat by UsersIDs
-----------------------------------

[](#option-2-load-the-chat-by-usersids)

### V1.0.0

[](#v100-1)

```
  return ChatLoader::LoadChatByUsersID($SenderID,$ReceiverID);

```

### V1.1.0

[](#v110-1)

```
   $sort = 'desc' // or 'asc'
   return ChatLoader::LoadChatByUsersID($SenderID,$ReceiverID,$sort);

```

### notes

[](#notes-2)

> ***Now , In the updated version of the package You can now specify the order of retrieved messages. If you want them from oldest to newest, set the $sort variable to 'ASC'or 'asc', the opposite is true for 'DESC' or 'desc'***

> ***The default of $sort is 'DESC'.***

Option 3: Load the chat by Scrolling
------------------------------------

[](#option-3-load-the-chat-by-scrolling)

`LoadChatByScrolling` is used to paginate messages efficiently. Instead of loading all messages at once, it loads a limited number of messages per request, improving performance.

### Parameters:

[](#parameters)

- **`$FirstUserID`** - The first user in the conversation.
- **`$SecondUserID`** - The second user in the conversation.
- **`$LatestMessageID`** *(optional)* - The ID of the last message received. If `null`, it loads the most recent messages.
- **`$no_messages`** *(optional)* - The number of messages to load per request. If `null`, it uses the 10 messages as a default limit.

### How It Works:

[](#how-it-works)

1. The first request should pass `null` for `$LatestMessageID` to load the latest messages.
2. Store the last message ID received.
3. For the next request, send the stored `$LatestMessageID` to fetch older messages.

### Example Usage:

[](#example-usage)

```
// First request (load latest messages)
$messages = ChatLoader::LoadChatByScrolling($user1, $user2);

// Get the last message ID from the response
$latestMessageID = $messages['LatestMessageID'];

// Next request (load older messages)
$olderMessages = ChatLoader::LoadChatByScrolling($user1, $user2, $latestMessageID);

// To get the messages , you must:
return $messages['Messages'];
```

### notes

[](#notes-3)

• The order of parameters has changed in the updated version of the package as below :-

### V1.0.0

[](#v100-2)

```
public static function LoadChatByScrolling($LatestMessageID,$FirstUserID,$SecondUserID,$no_messages = null)
```

### V1.1.0

[](#v110-2)

```
public static function LoadChatByScrolling($FirstUserID, $SecondUserID, $LatestMessageID = null, $no_messages = null);
```

Finally I have published the model , migrations and events files to your project ,In case you may like to customize them.
-------------------------------------------------------------------------------------------------------------------------

[](#finally-i-have-published-the-model--migrations-and-events-files-to-your-project-in-case-you-may-like-to-customize-them)

🚀 Updates in Latest Version `V1.1.0`
------------------------------------

[](#-updates-in-latest-version-v110)

### **Edit a message** using `editMessage`

[](#edit-a-message-using-editmessage)

- Modify an existing message with `MessageManager::editMessage()`

```
$bool = MessageManager::editMessage($message->id, 'How are you?!');
```

- Returns `true` if the edit was successful, `false` otherwise.

### **Delete a single message** using `deleteMessage`

[](#delete-a-single-message-using-deletemessage)

- Remove a specific message from the chat.

```
$bool = MessageManager::deleteMessage($message->id);
```

- Returns `true` if deleted successfully, `false` otherwise.

### **Delete multiple messages at once** using `deleteMessages`

[](#delete-multiple-messages-at-once-using-deletemessages)

- Pass an array of message IDs to delete multiple messages at once.

```
$ids = [4, 3, 5];
$bool = MessageManager::deleteMessages($ids);
```

- Returns `true` if all messages were deleted successfully, `false` otherwise.

Quality Assurance &amp; Testing
-------------------------------

[](#quality-assurance--testing)

This package has been thoroughly tested using **Laravel PHPUnit**, with **16 successful tests** ensuring its stability and high performance.

📌 You can check the test results below:

[![Screenshot-1575.png](https://camo.githubusercontent.com/97dcbb4d38970bae311ccf124bb3123d9b84e94d9a9bb9fec5de8aabe8171a29/68747470733a2f2f692e706f7374696d672e63632f737863794e76324d2f53637265656e73686f742d313537352e706e67)](https://postimg.cc/8fjqFkMG)

Contributing
------------

[](#contributing)

We welcome contributions from the community! If you'd like to contribute to this project, please follow these guidelines:

1. **Fork** the repository on GitHub.
2. Create a new branch for your feature or bug fix: `git checkout -b feature/awesome-feature`.
3. Make your changes and commit them: `git commit -am 'Add some feature'`.
4. Push your changes to the branch: `git push origin feature/awesome-feature`.
5. Create a new **Pull Request** (PR) on GitHub, describing your changes and why they should be merged.

Thank you for contributing to our project!

License
-------

[](#license)

This project is licensed under the MIT License.

Author
------

[](#author)

- [OmarAbulwahhab](https://github.com/OmarAbdelwahhab30)

Your support and contributions are greatly appreciated!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance49

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.7% 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 ~563 days

Total

2

Last Release

417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/71d0806f046c7a1ac7ee2194809143c12a297f865e131114db52f9242c1bee33?d=identicon)[OmarAbdelwahhab30](/maintainers/OmarAbdelwahhab30)

---

Top Contributors

[![OmarAbdelwahhab30](https://avatars.githubusercontent.com/u/99689683?v=4)](https://github.com/OmarAbdelwahhab30 "OmarAbdelwahhab30 (13 commits)")[![omarkishk](https://avatars.githubusercontent.com/u/125604976?v=4)](https://github.com/omarkishk "omarkishk (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/omarabdulwahhab-laramessenger/health.svg)

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

###  Alternatives

[michaeljennings/carpenter

A PHP package to create HTML tables from a data store that can be sorted and paginated.

191.7k](/packages/michaeljennings-carpenter)[lukesnowden/menu

Effortless menu building for Laravel 4

142.5k](/packages/lukesnowden-menu)

PHPackages © 2026

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