Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dazzz1er's avatar

[Package] Laravel 5 real-time chat

Hey guys I'm new here, but a big fan of the community and the videos!

I've recently been working on a few websites which require a real-time chat service between its users, so thought I'd put together a Laravel 5 package which adds real-time chat and messaging features to a website/application in a few lines of code.

It's pretty much an alpha at the moment, but if you're interested or are looking for something to use in your project, you can check it out at https://github.com/dazzz1er/confer and https://packagist.org/packages/djb/confer !

Dan

0 likes
14 replies
dazzz1er's avatar

@ufodisko I would like to host a demo for you, but the project uses Pusher for its real-time element which I currently only have a sandbox plan for (limits me to 20 concurrent users). I could perhaps set up a demo whereby each user coming to the demo site can log in as an available user (logging out frees up a user) so that it never exceeds 20, but it would take some time to implement.

If you are interested then perhaps the best way to demo for the moment is to download and try it out. Apologies that I can't be more helpful.

Ozan's avatar

@dazzz1er Well just pulling the package and using isn't a developer approach. Please show us a demo.

PS: Installation could be simpler. So much to do: views, view composers. All of these could be in a service provider.

Nice job mate!

dazzz1er's avatar

For those interested there is now a demo at http://www.confer.work (excuse the .work, it was cheap but now I like it!) which applies my demo scenario above. Try not to write any sensitive information (or rude things!) as user accounts are generic and messages persist across different users on the same account.

Ideally visit the site at the same time as a colleague/friend and private message each other... or you could just message another online user if available.

11 likes
Goranata's avatar

I've been using this and helped me a lot: Laravel tutorial: https://laracasts.com/lessons/broadcasting-events-in-laravel-5-1 The same tutorial explained much better: http://blog.nedex.io/laravel-5-1-broadcasting-events-using-redis-driver-socket-io/ (the guy has missed one things though, to register to event in App\Providers\EventServiceProvider.php)

When I click on submit on the chat, I use a different div id for each chat to be sent to, so the other user that I'm chatting can receive it only, and using jquery ajax post to insert the typed within the table 'messages', and in same time append it to my menu. Using this two packages, as well: https://github.com/tzookb/tbmsg https://github.com/fenos/Notifynder

2 likes
Red scorpion's avatar

@dazzz1er first of all realy good job with the chat. Have you been thinking about search feature in conversation threads?

dazzz1er's avatar

hi @Red scorpion sorry for the very late reply, I'm working on some other projects at the moment but a search feature would be a great addition to the package. Once I've updated the package to work with 5.1 then I will look to implement something like that :)

Rayzor286's avatar

Is there any possibility to update this package to laravel 5.1 ? Because I'm trying to add this package to my project in laravel 5.1 and it doesn't work :( It's a really good package to update ! Thank you and I can hepl if it's possible ! :)

bluecatworks's avatar

@dazzz1er first, let me thank you for your package, great work.

// App\Conversation.php

public function getChannel()
{
    return 'private-conversation-' . $this->id;
}

I've got a question regarding the code block above. As far as I know we can subscribe to any channel on client side via js.

My question is: Can this be considered as security hole since we can subscribe to it just knowing its id and some client side code exploring? And if yes, is there a way to protect channels better than just assigning random generated long string as a channel name?

1 like
sorcjc's avatar

@bluecatworks I am using an event class that implements ShouldBroadcast, and the channel name is defined in the broadcastOn method.

public function broadcastOn()
{
    return ['test-channel'];
}

I am using a "constant" channel, how I can use a variable channel name appending the user id? And, have you find a secure way to do it? Thanks in advance.

enasellithy's avatar

i worked on the same pakage and connection with app not working after auth login to app

Please or to participate in this conversation.