Deploying with Laravel Forge0:07
Ladies and gentlemen, I think we can all agree that nothing is ever truly finished. However, considering this is a video course and considering our time constraint, I think it's time to wrap up. So in this video, we're going to deploy our application using Laravel Forge. Why don't you come along? Let's visit forge.laravel.com. I already have an account, so I will log
dot Laravel dot com. I already have an account, so I will log in, I'll create a new server. Let's give it a name of pixel. This will only house our pixel website. I will leverage Laravel. VPS. Small is fine for of course a demo. Next, these credentials will only be displayed once. So I will download them and of course I'm gonna archive the
Pushing Code to GitHub0:44
So I will download them and of course I'm gonna archive the server at the end of the series. So don't try to copy this. Okay, let's create a new site, a Laravel site, and of course we're gonna fetch from GitHub. Yeah. So with that in mind, why don't we wrap up our local changes and push them up to GitHub back to our editor and the terminal.
and push them up to GitHub back to our editor and the terminal. Let's go full screen and I will do a git log. And yeah, you'll see I have a bunch of work in progresses while we work through this series. What I'm gonna do is reset to the beginning of section three and I'll copy this commit, and then I can do a git reset --soft. Uh, and this basically clears out of all of our commits, but it retains all of the changes.
Uh, and this basically clears out of all of our commits, but it retains all of the changes. So now if I do a git status, this is everything we did in section three, and this all encompasses our migration to, uh, view and inertia. Okay, so while we're here, let's do a composer format. And you will remember this will run both Rector and Pint. Okay? So once again, I'm gonna say gi, add to the staging area.
Okay? So once again, I'm gonna say git add to the staging area. I will commit with a message of migrate to view and inertia. And then I will push this up to GitHub. So now if I return to Forge, I can select our repository. It's called Laravel Workshop. We'll get the main branch. We're not gonna use a dedicated database, we'll just use SQLite. Our domain can be pixel.on.the.forge.com. I will install Composer.
Debugging Production 5002:08
Our domain can be pixel.on.forge.com. I will install Composer. Dependencies and that should be good. Alright, so we'll give this 20 seconds or so. Alright? And that's done. So it really did take about 20 seconds in real life. So now let's have a look. Let's see if it worked. Ah, we get a 500 error. That's okay. I, I might have expected that if we switch back, we can take a look in a couple ways.
I, I might have expected that if we switch back, we can take a look in a couple ways. First, I can launch the terminal and view the logs directly or I can go into observe logs. And here's our site log as you see here. And let's see what we have. VE manifest not found. Okay, I know exactly what this is. So let's do a couple things. Let's go into settings environment and open up my environment file or again I can SSH
Let's go into settings environment and open up my .env file or again I can ssh and uh, edit it manually, edit it, edited it. It's always awkward. Uh, anyways, if we scroll down for Database Connection, we're gonna use sqlite. And yeah, all of this can be commented out 'cause we're just using sqlite. Okay, so now if I scroll down, whenever we change, why don't we run php artisan config:cache? Uh, we don't have any queues,
Redeploying with Build Script3:16
whenever we change, why don't we run php artisan config:cache? Uh, we don't have any queues, but it's never a horrible idea to restart your queues and we'll save. And now let's do this. Let's go into deployments. And this is the deploy script that will run every time you push to production. You'll see it's cd to your release directory. It runs composer install, it runs npm run build, which is vet build.
It runs composer install, it runs npm run build, which is vet build. And then it optimizes our code base. Uh, creates your symlink. So let's give it one more deploy. So we're gonna force a manual deploy here because that vet manifest issue is related to um, something that should happen automatically when you run npm run build. So I'm curious what the issue might have been there. Let's take a look. And that's now done. If we scroll down, creates the symlink,
Let's take a look. And that's now done. If we scroll down, creates the sim link, it runs the migrations and the deployment is complete. So I feel like this should work. Why don't we try it one more time? Okay. And we get a black screen, but this is funny. So if we open up dev tools, you'll see, okay, route login is not in this list, okay? So this is actually part of section four that I want you to work on, but nonetheless we're gonna fix it real quick.
Adding Temporary Login Route4:20
So this is actually part of section four that I want you to work on, but nonetheless we're gonna fix it real quick. So let's go to our routes file. And yeah, you'll remember at the beginning of section three, uh, once I discovered we didn't have any registration forms, I wrapped this within a conditional just to protect ourselves, but just temporarily, I'm gonna destroy the server. Once we're done, I'm gonna remove this with the understanding that you would never actually include
Once we're done, I'm gonna remove this with the understanding that you would never actually include this in real life. Okay? So get login and why don't we say just give me the first User you find. We will assume they are the person we want to log in and then we redirect. And by the way, this is killing me here. I hate that. Alright, so let's commit return, temporary login endpoint.
Alright, so let's commit Return, temporary login endpoint. And I'm gonna push that up. And of course, because Forge has automatic deployment, it's going to detect this commit, pull on the changes, and then prepare a new deployment. And yeah, if I switch back to Forge, you could see our deployment and it's already complete super fast. Alright, so now let's visit again.
and it's already complete super fast. Alright, so now let's visit again. Alright, here's our splash page. Looks great. I will now click on our dummy sign in link and oh, we get a 500, but we would've expected this, right? We have a brand new database with no User and we were trying to assume that we had a User and we just don't. All right, that's okay. This gets me the opportunity to show you this launch terminal.
Creating User in Production5:39
All right, that's okay. This gets me the opportunity to show you this launch terminal. And this'll take us to the, remember we have zero downtime deployments. So your project itself will be stored within a current directory. Okay, very quickly, let's whip up a dummy User. Now, I believe Feld does a composer install --no-dev, which I think means we don't have access to Faker.
with no development dependencies, which I think means we don't have access to Faker. So we're just gonna do this manually, create a new User. I will fill the email address, I'll do myself, I'll set a password of bryt, change me, and maybe that's okay and we can save, whoops, forgot (). Okay, so now we have a User, we just need a Profile. So once again, let's fetch that User. Now I can say user->profile()->create(), and I'll paste these in.
So once again, let's fetch that User. Now I can say user profile, create, and I'll paste these in. All right, so we'll do myself displayName, Jeffrey, handle JeffreyWay bio. MyName is GIF and uh, that should do it. So we give it around and we now have a User in our system, but we did this directly through the Forge terminal, which is cool. All right, so now once again, if we visit, this should work. Sign in and there we go. We're signed in.
All right, so now once again, if we visit, this should work. Sign in and there we go. We're signed in. All right, so now we can make a post firstEverProductionPixelPost, give it a run, and we're in business. Congratulations.
