Download the PHP package saritasa/laravel-chat-api without Composer
On this page you can find all versions of the php package saritasa/laravel-chat-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-chat-api
Laravel Chat Api
Adds chat functionality for your project on top of Laravel Broadcasting feature.
Laravel 5.5+
Lower versions are not supported.
Installation and configuration Install the package:
Publish config with
Update config/laravel_chat_api.php sections:
- Implement IChatUser contract to your application user model and update parameter
userModelClass
. - Check notifications section and add your own notification instead this mocks.
Configure at least one broadcasting driver
Work with service Add IChatService contract injection in needed class.
Methods: - Create chat
Where [1, 2] - identifiers of participants of chat excluded creator.
-
Close chat
Remember that only creator can close chat and can't close "already closed" chat. In this cases ChatException will be
thrown. -
Leave chat
When creator leaves chat on of participants became to creator.
-
Send message in chat
- Mark chat as read
Events:
Chat events:
Throws in chat channel for all subscribers who participate in chatting.
- MessageSentEvent throws when participant sent new message in chat.
- ChatLeavedEvent throws when one of participants leaved this chat.
- ChatClosedEvent throws when creator closed this chat.
User events:
Throws in user channel for all subscribers who participate in chatting exclude event initiator.
- ChatCreatedEvent throws when user created new chat.
- MessageSentEvent throws when participant sent new message in chat.
- ChatClosedUserEvent throws when creator closed this chat.
- ChatReopenedUserEvent throws when creator reopened closed chat.
Broadcasting settings:
To integrate it with Laravel broadcasting you can just update your broadcasting routes file ( routes/channels.php by default ) with next example:
Read in official documentation about defining authorization callbacks. Now all chat events will dispatch through your broadcast driver.
Notifications settings:
To easy sent notifications you should create your own notification and update laravel_chat_api.php
config file.
Here is example if we should send notification when chat was reopened:
Contributing
- Create fork
- Checkout fork
- Develop locally as usual. Code must follow PSR-1, PSR-2
- Update README.md to describe new or changed functionality. Add changes description to CHANGE file.
- When ready, create pull request
Resources
All versions of laravel-chat-api with dependencies
illuminate/http Version 5.5
illuminate/support Version 5.5
saritasa/laravel-entity-services Version ^1.0
dingo/api Version 2.0.0-alpha1