Download the PHP package reliqarts/mardin without Composer
On this page you can find all versions of the php package reliqarts/mardin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reliqarts/mardin
More information about reliqarts/mardin
Files in reliqarts/mardin
Package mardin
Short Description Simplified real-time messaging for Laravel 5.
License MIT
Informations about the package mardin
Mardin Messenger
Mardin is a messaging package for Laravel 5.x based on Laravel Messenger.
Key Features
- Integrates seemlessly with your existing application.
- Supports multi-participant conversations (threads)
- Multiple conversations per user
- View the last message for each thread available
- Easily fetch all messages in the system, all messages associated to the user, or all message associated to the user with new/unread messages
- Fetch users unread message count easily
- Very flexible usage so you can implement your own access control
- Supports real-time messaging via integration with Laravel Echo
Installation & Usage
Installation
Install via composer; in console:
or require in composer.json:
then run composer update
in your terminal to pull it in.
Once this has finished, you will need to add the service provider to the providers array in your app.php config as follows:
Publish package resources and configuration:
You may opt to publish only configuration by using the config
tag:
Create a users
table if you do not have one already.
(Optional) Define names of database tables in laravel messenger's config file (config/laravel-messenger) if you don't want to use default ones:
See: Laravel messenger readme for more information on Laravel Messenger setup.
Run the migrations to create messages
, threads
, and participant
tables.
Configuration
-
Set the message model, participant model and thread model in laravel messenger's config file (config/laravel-messenger) to the provided Mardin models, or your custom models that extend these.
e.g.
-
Ensure your application is properly configured for broadcasting.
-
Ensure your application defines the
<base>
tag in its<head>
e.g.
This is used alongside mardinBase for routing. See: https://www.w3schools.com/tags/tag_base.asp
-
Set the desired environment variables so the package knows your user model, transformer, desired views, etc.
Example environment config:
These variables, and more are explained within the config file.
-
Include the mardin tray (message notification area) somewhere within your layout to initialize mardin. The mardin tray provides initialization parameters to Mardin's JS counterpart. (without these Mardin will not be initialized)
Example inclusion in
resources/views/layouts/app.blade.php
: -
Traits & Contracts
You must ensure that your user model and user transformer classes are properly set in your configuration (as shown above) and that they implement the
ReliQArts\Mardin\Contracts\User
andReliQArts\Mardin\Contracts\UserTransformer
contracts respectively.Your
User
model must also use theMessagable
trait.e.g. User model:
You may also extend the Message, Participant, and Thread models. Extending the
Message
model is encouraged since you may very well wish to add a specific policy for security (via Laravel Guard).e.g. Message model:
NB: Remember to update laravel messenger's config file (config/laravel-messenger) to reflect these.
-
Client-side Config
Install the JS counterpart via
npm
oryarn
:After adding the module via npm you may use as follows:
Note:
app
above refers to an instance of your client-side application and is optional.
And... it's ready! :ok_hand:
Usage
Routes
The following routes are made available. For clarification you may refer to the method documentations in ReliQArts\Mardin\Http\Controllers\MessagesController
here.
Authorization
Mardin supports Laravel's default authorization model. To use the provided policy, map the policy in your AuthServiceProvider
like so:
The policy uses the canSendMardinMessage()
and canReceiveMardinMessage()
methods implemented on the User
model. These methods are enforced by ReliQArts\Mardin\Contracts\User
.
Sending a Message
Start a new thread by making a request to messages/m/new
(POST).
Sample New Message Form
The above example uses laravelcollective/html
to generate a HTML form which posts to the create-message
route.
For more information on Laravel Messenger, check it out here.
:beers: cheers!
All versions of mardin with dependencies
illuminate/support Version ^5.5
doctrine/dbal Version ^2.5
pusher/pusher-php-server Version ^3.0
cmgmyr/messenger Version ^2.0
league/fractal Version ^0.13.0