I Welcome back to module three environments set up. We're moving into lesson 3.5 level tooling.
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.
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.
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.
We'll take advantage of the migrations.
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.
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,
and we're also going to take advantage of eloquent O R M O R O R M stands for object relational modelling
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.
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.
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,
which is the
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,
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
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.
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,
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.
So that is actually all we need to do for the vagrant file.
Now, in the script
that s H file. There's a couple lines that we need to add.
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,
and then we're also going apt get Why
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.
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.
And then we're gonna use composer to create our level project
in a letter arable directory, which we made up here.
And if we go back to that sink file command,
this is where that folder is going to be is going to end up.
So when this script is when the script is running, it is actually in this directory, which is home. Bagram.
So when we send the command to make directory level, it's going to make this additional folder
literal right here because we're actually in this directory when that's running.
so I did destroy
my last virtual machine from the previous lesson.
So if you need to do that, all you do is you type in vagrant
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
and just type in Bagram
Destroy. It's not I'm not gonna be able to cause already destroyed it.
And when it props you, Yes or no. Just be sure to click. Yes,
and then when it's gone and you have these files in place,
just select, vibrant up.
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.
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
and then select folder. And I'm just going to name it shared
Now, when I run bag ring up, it should work just fine.
And again, I'm gonna go ahead and fast forward through this because this will take a moment to complete everything.
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.
And, uh, I think that might be it. Migrations
and leave in the APP will be looking at some of the models that we create here.
So the models and the database
not too many, not a lot of the other ones. The other thing, the other following to look at is this dot M file.
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.
So we're going to need to make that level database,
and we're going to need to make sure that our credentials air correct. So it was route
and my password was set to the following.
So I'm going to say that
gonna get d beaver opening
and in our
bash, Shell will want to type in the command bag. Grint
Because when we run, the PHP are Titian commands will actually have to be in our
virtual machine for those commands to run
So I have d Beaver open. It's connected to the database,
and my veteran ssh! Is connected to the virtual machine.
So let's type in the command ls to see where I'm at. Now. I need to change directory, which is CD
and two terrible.
I wouldn't do ls again see what files? 1/2 those with same files in my shared director. Because we have sink
this directory. Now, if I do pwd, that's a command to show the full directory path
home vagrant level. We've sink the shared directory to this directory.
Now let's give the PHP artist in command.
They go PHP artists in
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.
So let's go ahead and run this command
and what we want to see is a successful migration.
actually, it should fail because I haven't created the level database yet.
Okay, so let's go create that level database.
Great new database.
let's take a look. And you could rename this. Of course.
Um, it doesn't have to be level. If you changed it here, you'd want to change it in the file,
So access the night of user route
for a short sales level. Okay, so you have got an air,
so let's try that command again.
Okay? It looks like I have a typo.
I spelled library wrong.
That's embarrassing. Let's give this another try.
So the setting file
have to make sure these database settings are correct
and let's migrate again.
And there we go. It has successfully migrated. Let's see if we got some tables in our database
on and we do. So these are the default tables that comes with, ah, level installation.
We probably are gonna be using these too much in our upcoming work, but we'll see.
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.
And that brings us to the summary of less than 3.5 level tooling.
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,
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,
and that again allows us to just edit the files on our host. And then it changes
to what we edited on the virtual machine as well.
And we once we did all that, we confirmed that the expected functionality was
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