Time
9 hours 41 minutes
Difficulty
Intermediate
CEU/CPE
10

Video Transcription

00:00
I Welcome back to module three environments set up. We're moving into lesson 3.5 level tooling.
00:08
So in this lesson, we're gonna take our development environment little bit further, and we're gonna integrate some level tools. Now, what is level level is a full stacked development framework based in PHP.
00:20
However, we aren't going to be using all the Web development tools associated with terrible. But we are gonna take advantage of the database components of the framework.
00:31
We're gonna take care we're gonna take advantage of the PHP artisan command line tool that comes with terrible applications. Provides commands for many level components. In our example will be using the database commands.
00:45
We'll take advantage of the migrations.
00:48
This allows us to define table structures in PHP files that could be in Stan Shih ated or rolled back at any time using PHP are Titian commands.
00:59
The file based design will allow programmers to use version control for their database design. So as you develop your database in these migration files, if you happen to be using some kind of version control, it will be much easier than if you weren't using files and instead we're just developing in my sequel,
01:18
and we're also going to take advantage of eloquent O R M O R O R M stands for object relational modelling
01:26
and allows us to create objects models with relationships. And this will be useful when we cede the database. And what seating the database means is that we're going to insert a bunch of the dummy data into our database.
01:40
And when you're working with constraints, foreign keys, primary keys, the modeling can really help a lot there now, with that said, Let's go head over to the virtual machine and get started with this set up.
01:55
All right, we're back at our virtual machine or I am and feel free to follow along. There are a couple edits we need to make to our file. We'll start with the easy one,
02:05
which is the
02:06
Bagram file.
02:07
We're in the directory that we were working in in the previous lesson, working with those vagrant file and the script dot s h fall,
02:16
and we need to add this line to the file, and these files will be available for download as well. So let's walk through very quickly what this Sync folder command is doing
02:27
so. This has taken a local shared folder that doesn't exist yet, and we're sinking it to this Target folder in the virtual Machine, which also doesn't exist yet. We haven't in Stan. She hated it in our script.
02:39
And then we're setting mount options and essentially, what this is doing this is very easy is it's just opening the permissions off that directory on that machine all the way up,
02:51
so there's no protections on it. And then we won't have to potentially deal with security permissions with that directory because we've just made it completely open, which you would not do in a production environment. But it is OK for development.
03:06
So that is actually all we need to do for the vagrant file.
03:12
Now, in the script
03:14
that s H file. There's a couple lines that we need to add.
03:16
First thing we're going to do is we're gonna make a directory. That's m K D. I. R level that's gonna make a level directory,
03:24
and then we're also going apt get Why
03:28
install So
03:30
all these
03:31
our PHP related components that we're going to request installation off and we're automatically going to say yes to any Yes, no questions.
03:43
Now the next line is going to download composer and install it in the Lenox, a boon to machine flora so that we can use composer.
03:52
And then we're gonna use composer to create our level project
03:57
in a letter arable directory, which we made up here.
04:01
And if we go back to that sink file command,
04:05
this is where that folder is going to be is going to end up.
04:11
So when this script is when the script is running, it is actually in this directory, which is home. Bagram.
04:17
So when we send the command to make directory level, it's going to make this additional folder
04:25
literal right here because we're actually in this directory when that's running.
04:31
Okay,
04:32
so I did destroy
04:34
my last virtual machine from the previous lesson.
04:38
So if you need to do that, all you do is you type in vagrant
04:42
destroy.
04:44
And also, if you need to open this terminal window, it's very easy. Go to the directory where your files air sitting. You right? Click, get Basheer
04:53
and just type in Bagram
04:55
Destroy. It's not I'm not gonna be able to cause already destroyed it.
04:59
And when it props you, Yes or no. Just be sure to click. Yes,
05:02
and then when it's gone and you have these files in place,
05:06
just select, vibrant up.
05:10
And it's gonna go through all the installations of those components. And I'm gonna go ahead and fast forward to the end of that because that will take a moment to complete.
05:18
All right, that was fast. Actually, we forgot to do something. And, you know, that happens on occasion. You got to be ready to deal with that. I forgot to make the shared folder. Now, the shared folder is being sink in the vagrant file. So we need to make sure that that folder exists on the host. So I'm gonna clicked, right click
05:38
and then select folder. And I'm just going to name it shared
05:42
Enter.
05:43
Now, when I run bag ring up, it should work just fine.
05:48
And again, I'm gonna go ahead and fast forward through this because this will take a moment to complete everything.
05:54
Okay? It looks like we've finished. So let's take a look at what we got here. We're going to the shared folder. We'll see a ton of files and folders, but we don't have to be overwhelmed by these. All these files and folders. We're not gonna be paying attention to a lot of them. We're going to focus on the database one.
06:11
And, uh, I think that might be it. Migrations
06:16
and leave in the APP will be looking at some of the models that we create here.
06:20
So the models and the database
06:24
not too many, not a lot of the other ones. The other thing, the other following to look at is this dot M file.
06:30
So this is a settings file and one of the settings in this fall, the only one we really need to pay attention to is the database one.
06:40
So we're going to need to make that level database,
06:44
and we're going to need to make sure that our credentials air correct. So it was route
06:49
and my password was set to the following.
06:54
So I'm going to say that
06:57
gonna get d beaver opening
07:03
and in our
07:05
bash, Shell will want to type in the command bag. Grint
07:11
Ssh!
07:13
Because when we run, the PHP are Titian commands will actually have to be in our
07:18
virtual machine for those commands to run
07:27
So I have d Beaver open. It's connected to the database,
07:31
and my veteran ssh! Is connected to the virtual machine.
07:35
So let's type in the command ls to see where I'm at. Now. I need to change directory, which is CD
07:42
and two terrible.
07:45
I wouldn't do ls again see what files? 1/2 those with same files in my shared director. Because we have sink
07:53
this directory. Now, if I do pwd, that's a command to show the full directory path
07:58
home vagrant level. We've sink the shared directory to this directory.
08:03
Now let's give the PHP artist in command.
08:07
They go PHP artists in
08:09
my great
08:11
and what this is going to do this gun issue command, it's gonna cause. Or it's gonna cause the level framework to migrate our database. Now, even though we haven't created some my any migrations ourself label comes with some by default. The user table for one is, ah, one example.
08:31
So let's go ahead and run this command
08:33
and what we want to see is a successful migration.
08:39
And
08:41
actually, it should fail because I haven't created the level database yet.
08:46
Okay, so let's go create that level database.
08:52
Great new database.
08:52
Terrible.
08:56
All right,
08:58
let's take a look. And you could rename this. Of course.
09:01
Um, it doesn't have to be level. If you changed it here, you'd want to change it in the file,
09:07
So access the night of user route
09:09
for a short sales level. Okay, so you have got an air,
09:13
so let's try that command again.
09:24
Okay? It looks like I have a typo.
09:28
I spelled library wrong.
09:31
That's embarrassing. Let's give this another try.
09:35
So the setting file
09:37
have to make sure these database settings are correct
09:41
and let's migrate again.
09:46
And there we go. It has successfully migrated. Let's see if we got some tables in our database
09:54
on and we do. So these are the default tables that comes with, ah, level installation.
10:00
We probably are gonna be using these too much in our upcoming work, but we'll see.
10:07
So that completes getting this environment prepped with some larible tooling. We've installed some tools that should help us with our database development. So let's shoot over to the summary and discuss what we went over.
10:20
And that brings us to the summary of less than 3.5 level tooling.
10:24
So what did we do in this lesson? Well, we did a few things. We adjusted the Vagrants Shell script to also installed wearable tools. So next time we deploy that script, it will also install level. In addition to my sequel,
10:37
we implemented a shared directory. The share directory provides a connection between at the local directory on the host machine and the Target directory on the virtual machine and sinks. Those so changes that happens in one is also reflected in the other,
10:56
and that again allows us to just edit the files on our host. And then it changes
11:01
to what we edited on the virtual machine as well.
11:05
And we once we did all that, we confirmed that the expected functionality was
11:11
present.
11:11
In addition, we discuss levels purpose in our project. We're not using the Web design components, but we are using the database design components to help us with maintaining and designing our database. So that brings this lesson to a close, and I hope you enjoy it and I'll see you in the next one. Thank you

Up Next

Intermediate SQL

This free course introduces the student to intermediate concepts found in the implementation and application of Structured Query Language (SQL) within professional business environments.

Instructed By

Instructor Profile Image
Kitt Parker
Instructor