Coding

Laravel Homestead Tutorial – #2 Setup

  • 00:00:00 so we finished at this point where we
  • 00:00:03 knew well which software homestead
  • 00:00:06 includes what it is what way current is
  • 00:00:09 and so on but not only is it important
  • 00:00:12 to know how to install it because we
  • 00:00:14 want to use it
  • 00:00:15 it also helps understanding of all these
  • 00:00:17 pieces work together once you've set it
  • 00:00:19 up so let's do this what we will need is
  • 00:00:22 vagrant some may just follow this link
  • 00:00:24 here and we'll also need either
  • 00:00:27 VirtualBox or VMware and these are the
  • 00:00:31 programs the tools which actually create
  • 00:00:34 and run the virtual machines I will
  • 00:00:36 choose VirtualBox here now on the
  • 00:00:39 respective websites you just download
  • 00:00:42 the software like VirtualBox for your
  • 00:00:44 operating system
  • 00:00:45 OS X in my case and I'll do the same for
  • 00:00:48 Waveland where I choose this subtle
  • 00:00:51 download button here to get to the
  • 00:00:53 download section and also download it
  • 00:00:55 for your operating system now this might
  • 00:00:59 take a couple of seconds and I will see
  • 00:01:01 you once this is finished so my
  • 00:01:03 downloads just finished and now I'm able
  • 00:01:06 to well first run VirtualBox and it over
  • 00:01:10 here just run this package here and next
  • 00:01:15 I'll just follow through the
  • 00:01:17 installation here that really isn't too
  • 00:01:19 difficult so let's finish this now once
  • 00:01:34 this is done close this and I will run
  • 00:01:37 the way grant installation it and it
  • 00:01:39 works the same way as the VirtualBox
  • 00:01:41 installation chests did let me get this
  • 00:01:44 over here to run extracts package here
  • 00:01:48 and then just run while the Installer
  • 00:01:51 here again I have to enter my password
  • 00:01:56 here so I do this and with that good to
  • 00:02:02 go so now we got VirtualBox in Waker and
  • 00:02:05 install the next step is to install
  • 00:02:07 homestead or to bring in homestead which
  • 00:02:10 really just as I said
  • 00:02:12 before it is this pre-configured box
  • 00:02:14 though also we later will have to
  • 00:02:18 install another part of Homestead which
  • 00:02:21 allows us to easily configure parts off
  • 00:02:24 the pre-configured box because the box
  • 00:02:27 itself yes it is pre-configured it is it
  • 00:02:30 contains the software you operating
  • 00:02:32 system of the software which you're
  • 00:02:33 under but we are able to change certain
  • 00:02:37 parts of the default configuration in a
  • 00:02:39 separate config file but you will see
  • 00:02:41 this so next the lower first next step
  • 00:02:45 is queue add this lateral homestead box
  • 00:02:49 to vagrant which is the provisioning
  • 00:02:51 system in the end and I do this in the
  • 00:02:54 command line by running way grant box ad
  • 00:02:56 and then level homestead
  • 00:03:02 and you're this one now just installed
  • 00:03:04 arable homestead and I have to choose
  • 00:03:06 which well virtual provider I use so I
  • 00:03:11 use VirtualBox here of course with just
  • 00:03:13 enter one and now just will download
  • 00:03:15 this box and well this has quite some
  • 00:03:19 size because remember it has complete
  • 00:03:21 operating system included and much more
  • 00:03:23 and therefore this will take a couple of
  • 00:03:25 minutes and I will see you once this is
  • 00:03:27 finished
  • 00:03:28 so my setup just finished here and the
  • 00:03:31 next step is to actually download the
  • 00:03:34 homestead initializer so to say which
  • 00:03:36 will set up the basic configuration
  • 00:03:40 homestead needs to actually start this
  • 00:03:43 box this homestead box and with
  • 00:03:47 configuration I mean not software on
  • 00:03:49 this box but how basically wavelet the
  • 00:03:53 virtual machine and our local machine
  • 00:03:55 works together which databases we have
  • 00:03:58 in our virtual machine and so on but I
  • 00:04:00 will go into more detail about the
  • 00:04:01 configuration of our vagrant box in a
  • 00:04:04 future video so how do we then install
  • 00:04:07 this configuration basically we get to
  • 00:04:10 come on here so we clone the github repo
  • 00:04:13 here with which includes this homestead
  • 00:04:17 configuration and I do this in the
  • 00:04:19 folder where I want to have my well my
  • 00:04:24 homestead config this is not necessarily
  • 00:04:28 the folder where your projects will live
  • 00:04:31 in but what I do is I will have my
  • 00:04:33 homestead folder on the same level where
  • 00:04:36 I will then have my different project
  • 00:04:39 folders or other sub folders but this is
  • 00:04:42 my personal preference you may install
  • 00:04:44 it where you want however it is
  • 00:04:46 important that you will start your
  • 00:04:48 virtual machine with the command vagrant
  • 00:04:51 up from within this folder so place it
  • 00:04:54 somewhere where you remember where it is
  • 00:04:57 so I'm now navigated into this folder
  • 00:04:59 this PHP folder my case and here I will
  • 00:05:01 run git clone then the link I just
  • 00:05:03 copied and then I will name my homestead
  • 00:05:06 folder well homestead address clones it
  • 00:05:09 into this folder now here's an important
  • 00:05:11 note for Windows users to follow along
  • 00:05:15 with
  • 00:05:15 these commands I execute a terminal here
  • 00:05:18 I recommend that you download git bash
  • 00:05:21 which is basically a tool which allows
  • 00:05:24 you to do just that run the same
  • 00:05:26 commands i'll run here on my Mac OS or
  • 00:05:29 on a Linux machine on Windows and this
  • 00:05:32 will make it far easier for you to
  • 00:05:33 follow along and I will base this video
  • 00:05:36 on the assumption that you are able to
  • 00:05:38 follow along with these commands so I
  • 00:05:40 cloned this into this folder and next I
  • 00:05:43 will well move into this home step
  • 00:05:45 folder and in there what I will do is I
  • 00:05:47 will then run with the bash tool this
  • 00:05:52 init shell script which copies some
  • 00:05:56 basic initialization files and yeah sets
  • 00:05:59 up homestead configuration the way we
  • 00:06:02 need it with this we're almost ready to
  • 00:06:05 run everything but I want to first
  • 00:06:08 navigate to the folder where the actual
  • 00:06:11 config file will be stored this is the
  • 00:06:16 root user folder and in here I got my
  • 00:06:20 home state yamo file and it's just a
  • 00:06:24 text file in the end where well the
  • 00:06:28 configuration takes place now I will go
  • 00:06:32 over this file in the next video however
  • 00:06:35 what is important
  • 00:06:37 vagrant or the virtual machine maps a
  • 00:06:40 certain folder to a folder on your local
  • 00:06:43 machine to keep the files synchronized
  • 00:06:46 because otherwise you would have a
  • 00:06:47 problem because of course you want to
  • 00:06:49 develop on our local machine with our
  • 00:06:51 local IDE s for example but we want to
  • 00:06:55 exit to execute to access these files
  • 00:06:58 through a browser for example if you're
  • 00:07:01 creating a website but these files then
  • 00:07:03 have to be on a virtual machine because
  • 00:07:05 this machine has the server right so how
  • 00:07:08 do we get our locally develop files on
  • 00:07:11 that machine the great thing is vagrant
  • 00:07:13 has this synchronized folder concept
  • 00:07:16 where files in this folder will be
  • 00:07:19 automatically copied so to say into the
  • 00:07:23 virtual machine so that all the changes
  • 00:07:26 we do in our
  • 00:07:27 local machine will be reflected in the
  • 00:07:29 virtual machine and therefore we can
  • 00:07:31 develop locally but test on the virtual
  • 00:07:34 machine and this is what we do here with
  • 00:07:36 the folders key here we define which
  • 00:07:40 local folder the map key we want to map
  • 00:07:45 to which virtual folder to now add a
  • 00:07:49 virtual folder for me as fine home right
  • 00:07:51 way current code is okay but I don't
  • 00:07:53 code in the code folder I code to show
  • 00:07:57 this in a Finder I'm here in my root
  • 00:08:02 user folder under development than PHP
  • 00:08:05 for PHP projects and then your tutorials
  • 00:08:09 or projects so I want to have this PHP
  • 00:08:11 file as my root folder to be
  • 00:08:13 synchronized in order to do this I will
  • 00:08:17 map this here from well development PHP
  • 00:08:22 and you replaced as pop which with
  • 00:08:25 whichever path you need from your root
  • 00:08:28 file on down to the filer your actual
  • 00:08:31 projects will well sit in and you may
  • 00:08:34 map this to one single project or like I
  • 00:08:38 do here to a folder which contains
  • 00:08:40 several projects so this Maps this
  • 00:08:42 folder however this alone won't allow me
  • 00:08:46 to run applications in the browser I
  • 00:08:48 will have to map my sites here too this
  • 00:08:52 will make sure that my files are
  • 00:08:54 synchronized with the machine but in
  • 00:08:56 order to access my my websites there I
  • 00:08:59 have to tell why vagrant or homestead to
  • 00:09:04 which projects certain URL should relate
  • 00:09:08 and I can do this here by let's say I
  • 00:09:12 want to have my level basics tutorial I
  • 00:09:15 will use dot dev as extension but you
  • 00:09:19 may choose whatever you want here and
  • 00:09:21 now this home way grant code file is
  • 00:09:24 okay because this is the virtual machine
  • 00:09:26 path where my projects sit in now here
  • 00:09:30 again we're on a virtual machine like we
  • 00:09:32 were here but this part here is wrong
  • 00:09:36 because if we have a look at my
  • 00:09:38 structure here
  • 00:09:39 is home wagon code file relates to this
  • 00:09:44 PHP folder here now in there I have my
  • 00:09:47 tutorials I have YouTube and then for
  • 00:09:50 example here level basics so if I want
  • 00:09:53 to map this project what I will do is I
  • 00:09:56 will replace level here because the
  • 00:09:58 public folder should say the same
  • 00:10:00 because our index.php will always be the
  • 00:10:02 public folder and little project
  • 00:10:05 so whatever the here is I will replace
  • 00:10:07 level with tutorials and then YouTube
  • 00:10:12 and then wearable basics so tutorials
  • 00:10:16 YouTube level basics and this will make
  • 00:10:20 sure that I'm mapping my actual project
  • 00:10:24 to this URL on the virtual machine now I
  • 00:10:29 will close this and now I have an
  • 00:10:31 additional step to do in order for just
  • 00:10:34 to work in my browser I also have to
  • 00:10:38 create a mapping on my local machine
  • 00:10:40 from well the URL I want to use to the
  • 00:10:45 IP of the virtual machine and this IP
  • 00:10:49 while you could see it in this homestead
  • 00:10:52 Yammer file here at the very top this is
  • 00:10:57 the IP we will need so I will do this
  • 00:11:01 next I do this by running sudo nano
  • 00:11:04 pseudo is required on Mac to get well
  • 00:11:08 access to this nano is a little text
  • 00:11:11 editor command line text editor and then
  • 00:11:14 I want to add edit my e.t.c hosts file
  • 00:11:17 now on windows letter will schedule
  • 00:11:20 covered if you scroll down and down and
  • 00:11:22 down here the hosts file you'll find a
  • 00:11:25 description where to find the hosts file
  • 00:11:27 on a Windows machine what we basically
  • 00:11:30 do in this file is we can map IPS to
  • 00:11:33 certain domain names which we then can
  • 00:11:36 enter in the browser we don't have to do
  • 00:11:38 this
  • 00:11:39 this is GIP from the ammo file but of
  • 00:11:41 course it's easier to type a domain name
  • 00:11:43 into the browser than this IP just make
  • 00:11:46 sure to not bind a domain
  • 00:11:48 your which might serve an actual website
  • 00:11:51 like google.com for example because then
  • 00:11:53 you would not be able to access this
  • 00:11:55 page anymore so here I will then map
  • 00:11:59 this IP to level basics death and then I
  • 00:12:05 access exit with control X press Y to
  • 00:12:09 save it and enter again now with this
  • 00:12:13 still in my homestead folder where I
  • 00:12:15 cloned the git repository into I can now
  • 00:12:19 run vagrant up to start my virtual
  • 00:12:24 machine based on the configuration I set
  • 00:12:27 up here and this will take a couple of
  • 00:12:30 seconds and we'll be back once it is
  • 00:12:32 finished
  • 00:12:33 so there's finished for me you may
  • 00:12:35 ignore this red warning here or error
  • 00:12:38 that is nothing too bad and now I can
  • 00:12:42 access this page under level basics duck
  • 00:12:45 death and as you can see here is my page
  • 00:12:48 so it doesn't spin the installation how
  • 00:12:50 to set it up and next we will have a
  • 00:12:52 look at how to configure it and how to
  • 00:12:55 for example access to database from our
  • 00:12:57 local machine and how to run our tests
  • 00:13:00 and commands for example