Playing
01. Introduction and setup

Transcript

00:00
In this course we're going to set up Sockety in Laravel and look at broadcasting real-time events on public and private channels. Sockety is a real-time web server and we can use this as a direct replacement to services like Pusher which makes it a much cheaper option if you're just getting started or if you have a lower budget. And this integrates really nicely with Laravel's default broadcasting functionality
00:23
so we don't really need to do too much setup within Laravel itself. Sockety is also incredibly fast and it can scale so you might just end up using it instead of a paid service. So let's dive in with a fresh Laravel project and we're going to go ahead and use the command line here to create our Sockety Basics project with the Laravel Installer.
00:46
Okay, so that's all installed. The first thing that we'll do is go ahead and just run php artisan serve just to grab a development server and you can see that in the browser now.
00:56
And if we just head over to our EMV file we are going to be using the database here. So let's switch the connection over here. You of course might be using MySQL which is absolutely fine and let's go ahead and grab the database name so we can create a fresh database as well.
01:11
I'm just going to switch the username around and we're pretty much done. Okay, so I've gone ahead and created the empty database just over here and what we're going to do is just go ahead and run php artisan migrate over here. So let's create out a new tab very quickly and run php artisan migrate
01:30
and as we can see that's not worked. So let's just have a look. Let's just double check this. That should be 5 4 3 2.
01:39
There we go. Okay, so that's done. Okay, so we've got a fresh Laravel app up and running for the purpose of this. We're going to go ahead and use the Laravel Breeze starter kit
01:50
just so we have some authentication in place. The reason that we're going to do that is because as part of this, we're going to look at private channels which require the user to be authenticated. So if you're pushing broadcast events to a specific user on a specific channel
02:06
and you have some kind of condition around that is likely that they're going to be signed in as a user. So let's head over to the Laravel Breeze installation section. Go ahead and grab the composer command to go ahead and install this. While that's doing let's look at what else we need to do.
02:21
We need to run the Breeze install command to publish the controllers. Let's do that. And then we just need to run npm install npm run dev and finally php artisan migrate which we shouldn't need to do because we've already done.
02:33
So let's go ahead and do npm install and npm run dev and we should be good when this is finished. Okay, so that's all finished. If we head back over to the browser here, we should be able to register an account. So let's go ahead and just fill in some details here.
02:49
And now we've done that let's register and there we are over in our dashboard. So for the purpose of this we're not going to be creating anything too useful. We're just going to be within JavaScript listening for these events and dumping them out to the console. What you can then do is integrate this into perhaps view
03:06
or whichever front-end language you're using or whichever front-end framework you're using. So you leave the console open just here so we can go ahead and see that dumped out. Okay, we're all set up the next episode. We're going to set Sockety up and configure it.
5 episodes 26 mins

Overview

Learn to broadcast events in realtime with Soketi, a simple, fast, and resilient open-source WebSockets server.

In this course, we'll set up a Soketi server, configure Laravel for Soketi, and create events for public and private channels. Then, we'll listen for these events on the client and dump the payload from the server.

If you need realtime events in your app, this course will get you up and running in no time.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.