Git Product home page Git Product logo

messenger-ui's Introduction

Messenger UI

Latest Version on Packagist Total Downloads StyleCI License


Preview


Ready-made UI and web routes for use with rtippin/messenger

Notes

  • This package provides web routes and a published UI to consume messenger's API. No authentication routes/system will be setup for you.
  • Our compiled NotifyManager.js uses laravel echo, with the pusher-js library.
  • For websockets, this package supports pusher.com directly, or the drop-in replacement laravel-websockets.
    • Instructions are located below for setting up the websocket implementation of your choosing.
  • After publishing our views, you may wish to edit them to fit your needs.
  • Future versions planned will be crafted in react.

Installation

Via Composer

composer require rtippin/messenger-ui

Publish Assets and Config

  • This will publish our JS assets, images, views, and config.
php artisan messenger:ui:publish
  • When using composer to update this package, we recommend republishing our JS/CSS assets:
php artisan vendor:publish --tag=messenger-ui.assets --force

Config

Default:

'site_name' => env('MESSENGER_SITE_NAME', 'Messenger'),

'websocket' => [
    'pusher' => env('MESSENGER_SOCKET_PUSHER', false),
    'host' => env('MESSENGER_SOCKET_HOST', 'localhost'),
    'auth_endpoint' => env('MESSENGER_SOCKET_AUTH_ENDPOINT', '/api/broadcasting/auth'),
    'key' => env('MESSENGER_SOCKET_KEY'),
    'port' => env('MESSENGER_SOCKET_PORT', 6001),
    'use_tsl' => env('MESSENGER_SOCKET_TLS', false),
    'cluster' => env('MESSENGER_SOCKET_CLUSTER'),
],

'routing' => [
    'domain' => null,
    'prefix' => 'messenger',
    'middleware' => ['web', 'auth', 'messenger.provider'],
    'invite_middleware' => ['web', 'messenger.provider'],
],
  • site_name is used in our views to inject the name in the navbar.
  • websocket:
    • When using the real pusher.com, you need to set pusher to true, add in your cluster, and your key.
    • When using laravel-websockets, you leave pusher to false, ignore cluster, and set your host, port, and key.
    • The auth_endpoint is for your laravel's backend to authorize access to our messenger channels. The default messenger.php config prefixes the channel routes with api, hence our default config above uses /api/broadcasting/auth when not set.
  • routing you may choose your desired endpoint domain, prefix and middleware.
    • Invite join web route you can define separate middleware from the rest of the web routes, as you may want a guest allowed to view that page.
    • The default messenger.provider middleware is included with messenger and simply sets the active messenger provider by grabbing the authenticated user from $request->user().

Using Pusher

  • After you have your pusher credentials ready, you should install the pusher SDK:
composer require pusher/pusher-php-server
  • Once installed, set your .env variables:

Default broadcasting.php config

'pusher' => [
    'driver' => 'pusher',
    'key' => env('PUSHER_APP_KEY'),
    'secret' => env('PUSHER_APP_SECRET'),
    'app_id' => env('PUSHER_APP_ID'),
    'options' => [
        'cluster' => env('PUSHER_APP_CLUSTER'),
        'useTLS' => false,
    ],
], 

.env keys for both pusher and our UI

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=YourPusherId
PUSHER_APP_KEY=YourPusherKey
PUSHER_APP_SECRET=YourPusherSecret
PUSHER_APP_CLUSTER=YourPusherCluster
MESSENGER_SOCKET_PUSHER=true
MESSENGER_SOCKET_KEY="${PUSHER_APP_KEY}"
MESSENGER_SOCKET_CLUSTER="${PUSHER_APP_CLUSTER}"
  • You are all set! Our UI will connect to your pusher account. Be sure to enable client events within your pusher account if you want our client to client events enabled.

  • First, you need to have installed the websocket package (This package has been tested using laravel-websockets v1.12).
  • Ideally, you should follow the official Installation Documentation from beyondcode if you are doing a fresh installation.
composer require beyondcode/laravel-websockets "^1.12"
  • Once you have installed and configured the websocket package, set your .env variables and update the default pusher config:

Updated broadcasting.php config per beyondcode's documentation

'pusher' => [
    'driver' => 'pusher',
    'key' => env('PUSHER_APP_KEY'),
    'secret' => env('PUSHER_APP_SECRET'),
    'app_id' => env('PUSHER_APP_ID'),
    'options' => [
        'cluster' => env('PUSHER_APP_CLUSTER'),
        'encrypted' => true,
        'host' => 'localhost',
        'port' => 6001,
        'scheme' => 'http'
    ],
],

.env keys for both laravel-websockets and our UI

BROADCAST_DRIVER=pusher
PUSHER_APP_ID=MakeYourID
PUSHER_APP_KEY=MakeYourKey
PUSHER_APP_SECRET=MakeYourSecret
MESSENGER_SOCKET_HOST=localhost
MESSENGER_SOCKET_KEY="${PUSHER_APP_KEY}"
  • You are all set! Our UI will connect to your server running php artisan websockets:serve. Be sure to enable client events in your laravel-websockets config if you want our client to client events enabled.

messenger-ui's People

Contributors

rtippin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

messenger-ui's Issues

Group Voice Call

Hello,
Thank you for this great package,
Please, how could I use it to make a group voice call (same as twitter space) using a janus server ?
Thanks

How to hide actions btns?

How to hide thread dropdown menu, knocks and close btns? and also message msg reaction, forward, etc.,?
Screenshot (114)

Retiring MomentJS

Hello,

As per their front page, MomentJS is more or less retired. It also increases considerably the size of the bundle.

I personally favor DayJS, which is more reliable (immutability) and lighter (modular).

Regards

Read messages

Is there any way to display some "read mark" on messages in private thread (not like head bobbles)?

How to search in all users? And add participants in a group?

1. How can a user search all users (including new fresh users) for conversations?

In the users table

Getting only logged in user

I want to get search results from all new users. Logged in or not.

in user model

Implements

class User extends Authenticatable implements MessengerProvider

Using traite

use Messageable;

Setting method

   public static function getProviderSettings(): array
    {
        return [
            'alias' => 'user',
            'searchable' => true,
            'friendable' => true,
            'devices' => true,
            'default_avatar' => public_path('vendor/messenger/images/users.png'),
            'cant_message_first' => [],
            'cant_search' => [],
            'cant_friend' => [],
        ];
    }

Searchable method

   public static function getProviderSearchableBuilder(
        Builder $query,
        string $search,
        array $searchItems
    ) {
        $query->where(function (Builder $query) use ($searchItems) {
            foreach ($searchItems as $item) {
                $query->orWhere('name', 'LIKE', "%{$item}%");
            }
        })->orWhere('email', '=', $search);
    }

2. How can users add participants in a group without being friends?

I am using BIGINT id in the users table

The messages I sent are displayed incorrectly

Hello! When I send a message, it does not stand out that I sent it. My and the other person's messages are displayed on the left, although mine should be displayed on the right and highlighted in blue. Everything works in the demo version, but installing this package Laravel 8 and Jetstream works incorrectly.

image

Messages not live updating

Hello

First of all, thanks for the amazing package in both Messenger and Messenger UI for Laravel, what an amazing job!!

Running into a little issue though. When sending messages, they do not appear for the other user, first after a reload of the page. But Online status, writing bubbles, and other events works just fine.

Do you have any idea what the issue could be here?

Thanks in advance ๐Ÿ˜„

Tried reaching your email, but didn't work..

Adding a line break in messages (Shift + enter)

Hi, I'm trying to add a line break, I have already added a condition that recognizes enter and shiftEnter:
image
I also changed the input to textArray. I looked in the database and they also write enter. However, I have a problem with displaying it in the message. Can you help?

Regarding frontend customization

If I want to change or customize the front end to fit my overall website design, how would I go about doing that?
Please advise and thank you for your time.

config socket.io

hi, this is a very good package and i like it, but i want to use socket.io and laravel-echo-server as an alternative to pusher, how to configure it, looking forward to your reply

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.