do you make the auth?
php artisan make:auth
It will give you the possibility to register and authenticate a user.
Greetings Dennis
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I'm following this tutorial for making a chat:
https://blog.pusher.com/how-to-build-a-laravel-chat-app-with-pusher/
I can't get this to work. I'm trying for 3 hours now but still no result.
At the beginning I read this:
Before we start using Laravel event broadcasting, we first need to register the App\Providers\BroadcastServiceProvider. Open config/app.php and uncomment App\Providers\BroadcastServiceProvider in the providers array.
So I've done that. If I do that I receive a 404 in my network tab with this url:
localhost/broadcasting/auth
But if I uncomment it (App\Providers\BroadcastServiceProvider) I receive no errors anymore but my chat is not working (only with a refresh).
If I look into my pusher dashboard I can see that connections are being made but no messages are being send.
Any idea what could be wrong?
--EDIT--
Front end code:
bootstrap.js
import Echo from "laravel-echo";
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'mykey',
cluster: 'eu',
encrypted: true
});
app.js
// resources/assets/js/app.js
require('./bootstrap');
Vue.component('chat-messages', require('./components/ChatMessage.vue'));
Vue.component('chat-form', require('./components/ChatForm.vue'));
const app = new Vue({
el: '#app',
data: {
messages: []
},
created() {
this.fetchMessages();
Echo.private('chat')
.listen('MessageSent', (e) => {
this.messages.push({
message: e.message.message,
user: e.user
});
});
},
methods: {
fetchMessages() {
axios.get('/messages').then(response => {
this.messages = response.data;
});
},
addMessage(message) {
this.messages.push(message);
axios.post('/messages', message).then(response => {
console.log(response.data);
});
}
}
});
ChatMessage.vue
<template>
<ul class="chat">
<li class="left clearfix" v-for="message in messages">
<div class="chat-body clearfix">
<div class="header">
<strong class="primary-font">
{{ message.user.name }}
</strong>
</div>
<p>
{{ message.message }}
</p>
</div>
</li>
</ul>
</template>
<script>
export default {
props: ['messages']
};
</script>
ChatForm.vue
<template>
<div class="input-group">
<input id="btn-input" type="text" name="message" class="form-control input-sm" placeholder="Type your message here..." v-model="newMessage" @keyup.enter="sendMessage">
<span class="input-group-btn">
<button class="btn btn-primary btn-sm" id="btn-chat" @click="sendMessage">
Send
</button>
</span>
</div>
</template>
<script>
export default {
props: ['user'],
data() {
return {
newMessage: ''
}
},
methods: {
sendMessage() {
this.$emit('messagesent', {
user: this.user,
message: this.newMessage
});
this.newMessage = ''
}
}
}
</script>
I used this tutorial and got it working with no issues and I am running it on Homestead.
https://jplhomer.org/2017/01/building-realtime-chat-app-laravel-5-4-vuejs/
Please or to participate in this conversation.