A simple package for you to implement a chat in your application without effort !
LaraMessenger is a Laravel package that provides messaging functionality for your Laravel application. Follow these steps to get started:
You can install LaraMessenger using Composer. Open your terminal and run the following command:
composer require omarabdulwahhab/laramessenger
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.
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.
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)
->build();
/*HERE YOU HAVE TO OPTIONS*/
// 1- $config->broadcast();
// OR
// 2- $config->send();
You can use broadcasting with pusher in the package but make sure to integrate with pusher , read this doc section
$config->broadcast()
$config->send()
• ->setMessageType($request->type) // Make sure to set a type to one of them ['file','text','voice'] otherwise it will not work!
That's it! You've successfully send a message in LaraMessenger .
return ChatLoader::LoadChatByChatID($ChatID);
return ChatLoader::LoadChatByUsersID($SenderID,$ReceiverID);
This function will return the chat with the latest message ID to store it and send it again with next request and so on
return ChatLoader::LoadChatByScrolling($latestMessageID,$SenderID,$ReceiverID,$NoOfMessagesPerPage);
Finally I have published the model , migrations and events files to your project ,In case you may like to customize them.
We welcome contributions from the community! If you'd like to contribute to this project, please follow these guidelines:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix:
git checkout -b feature/awesome-feature
. - Make your changes and commit them:
git commit -am 'Add some feature'
. - Push your changes to the branch:
git push origin feature/awesome-feature
. - Create a new Pull Request (PR) on GitHub, describing your changes and why they should be merged.
Thank you for contributing to our project!
This project is licensed under the MIT License.
Your support and contributions are greatly appreciated!