Playing
02. Setting up the example project

Transcript

00:00
Following along with this course is, of course, optional, but if you do want to, we have an example project in the download section which you can grab and set up ready to follow with every single episode.
00:11
So in this video, if you are new, I'm just going to show you how to set this up once you have it downloaded and running on a web server. So if you do have it running on a web server right now, you'll probably see something like this. That's because we haven't included any of the composer dependencies or anything like that. So let's go ahead and just get started with that.
00:31
We're going to, first of all, do a composer install within the main directory here. That's going to go ahead and just pull all of our dependencies down. What we're also going to do is an npm install as well. So let's run that, too, just to put in all of the dependencies for our front end.
00:46
And once you've done that, you're going to want to run and leave running npm run dev. So if we head over now and just give that a refresh, you can see that, sure enough, we have progressed a little bit. Next step is to go ahead and create our database called Laravel underscore performance. And of course, if you have worked with Laravel before, you know that you can tweak that just over here.
01:08
And of course, you're also going to want to update all of your database settings in here as well. So I'm running Postgres, but if you're using MySQL, that is absolutely fine. Next step in that case is to run PHP artisan migrate just to create out all of the base tables that we need, including posts and users, which are the main two things we're going to be working with.
01:28
And that should give you something like this. Now, this first page here, as we saw from the introduction, is just a list of articles. So in this case, we want to generate out some fake data. Now, as part of this example project, if we just head over to the database section here,
01:46
we have a blog seeder already created, or you can do this on the command line using Laravel Tinker. So what this is going to do is use the default user factory, which exists over in the factory just here. So that gives us a fake list of all of the attributes that a particular user can have. And it will create five users and they have 100 posts each.
02:11
So if we just take a look into the user model, you can see that the relationship here is already set up to the post model. And this has 100 each and we just create them simple as it is using Laravel factories. So to actually generate out this data, we're going to go ahead and run PHP artisan db seed. And we're going to choose the name of the seeder. In this case, it's blog seeder.
02:34
Give that a few seconds to run and you should have a load of data in your database. You can see here, of course, we've got 500 articles because we have 10 users with 100 posts each. Aside from that, there's not really much to do. So we're going to head over to the next episode where we're going to analyze this page using Laravel debug bar.
15 episodes1 hr 9 mins

Overview

Let's keep our Laravel applications feeling snappy! In this course, we cover the absolute fundamentals you need to keep in mind when building anything with Laravel.

While Laravel handles a lot for you, it's easy to fall into the trap of not considering and monitoring performance as you go. Keep these tips in your toolbelt, and you'll be able to develop faster apps, from the beginning.

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

Comments

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