Playing
02. Up and running locally

Transcript

00:00
If you want to follow along every single step in this episode and the next episode, we're going to focus on getting this application, this example application working locally, and then actually creating a Forge server and deploying this.
00:12
If you already have an application deployed and ready to go, but real time isn't working, feel free to skip the next couple of episodes and jump straight into configuring Forge. Okay.
00:23
If you head over to the source code for this course, you'll see that we have an example application here. Let's go ahead and pull this down and we will get this working locally. First of all.
00:33
Okay. So in your terminal, let's go ahead and clone this down first of all. And once that's finished, let's go into that directory and open this up in our editor. This uses SQLite locally, so you don't need to worry about setting up a database,
00:45
but of course we're going to go ahead and get everything installed. So let's run a composer install first of all, to pull down all of our dependencies. Then we'll go ahead and run npm install so we can get all of our node dependencies working as well.
00:59
Next up, because we are using SQLite, we need to touch a database file. So let's do that in the database directory and create database.sqlite. Next up, we'll go ahead and migrate everything. So let's run our migrations to create them.
01:14
And finally, we'll go ahead and run npm run dev to build all of our assets. Now within this example application, reverb is already up and running. So let's go ahead and run php artisan reverb start. And we'll just choose the debug option just so we can check if anything goes wrong.
01:29
Okay. Now, if you followed all of them steps, if you open this up, however, you're serving your application, you should see a fresh Laravel app. Now, just before we dive into this, really importantly, within this
01:40
repository, I've gone ahead and included the EMV file. Usually you wouldn't deploy that, but I've gone ahead and put it in there anyway. So when we do deploy this, the EMV file is going to get pushed up to our server, but usually what we would do is manually copy this over and
01:55
adjust the configuration within Forge. We'll talk about that in a second, but I left it in here. So you could see all of the default configuration options that we have for reverb at the moment, which is just everything that you would
02:05
get when you install this locally. Okay. So now that we've done that, let's go ahead and just register out on account really quickly.
02:12
So let's enter some credentials here. And once we're in, we'll be forwarded over to the dashboard where we have this button just here. If you click this and this is rolling in, you know, that real time is working locally.
02:26
Let's just have a really quick look at the code just to see what this does. So if we head over to the dashboard file here, we're just using Alpine JS here to store a list of messages. This button just down here goes ahead and invokes this broadcast message, which
02:40
sends a fetch request over to our web routes. If we take a look at our web routes, you'll see that we've got this broadcast here, which is sending an anonymous event over on this global channel as message with a random string in the body.
02:55
And that's what we see appearing on the dashboard. When we click this button, we go back over. Once this has been sent to the backend, we are now listing with Laravel Echo on this channel for that message.
03:06
And we're pushing that to the stack of messages, which is getting rendered out here, so a really simple example, but obviously if you have this working locally now, you know that you have broadcasting actually set up within an app in the next step, we'll actually go ahead and deploy this again.
03:21
If you already have an application deployed, feel free to skip this. And then once we have deployed this, of course, throughout the rest of the course, we'll go through every step. We need to get this working.
7 episodes 16 mins

Overview

So you’ve built a realtime application. Now it’s time to deploy it.

Laravel Forge makes it incredibly easy to toggle Reverb, which configures your server for you and sets up (nearly) everything you need to broadcast and listen for events.

In this course, we’ll cover every step needed to get an local example application deployed to a production server, with a separate subdomain reserved for your Reverb connections.

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

Comments

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