- [Instructor] Welcome to Starting Our Laravel Project. To do this, we're going to use a tool that Laravel provides called Homestead. Homestead is going to require the installation of some software that we can find on the web. Homestead requires the installation of Vagrant, which can be found at Vagrantup.com. Vagrant, which is free and available for any platform, gives us the ability to install virtual environments for our development users. However, we also need one other piece of software. We need some accompanying virtualization software. This could be and in most cases, will be a tool called VirtualBox. VirtualBox is also free and available for all platforms. You can install VirtualBox now by going to Virtualbox.org, clicking on the Download VirtualBox button, and downloading and installing the package that matches your platform, whether you're Windows OS 10 or Linux. If you're on the Mac, you can also use a tool called Parallels. Parallels, however, is a paid tool and you'll have to spend money on it. You can also use a tool called VMWare possibly. Again, this is a paid tool. If you're on Windows 10 Enterprise, Pro, or the Education version, you can also use Hyper-V. Hyper-V enables you to run virtualization software on your Windows 10 machine. Notice, it is not available if you're using Windows 10 Home. Once both Vagrant and one of the virtualization software options are installed and set up, we can continue on with this video. We can get started by setting up our Homestead box. This is Laravel's tool to provide us a common development platform, meaning you and I don't have to worry about having different PHP versions or ensuring that you have some piece of specific database software installed. Homestead doesn't enable us to deploy our application to the web, but it does make it easy for us to develop our applications locally before deployment. What we'll need to do is we'll open up our Terminal application and we'll run a command. The command is vagrant box add laravel/homestead - -box-version 8.1.0. You'll note I'm selecting a precise version of the Homestead box. That's because I want to be sure we're all using the same version of Homestead and the same version of the underlying software to run our Laravel project. That being said, if you want to use a newer version of Homestead, it should still work, though you may see some edge cases. You'll see on the screen that you'll need to select the precise provider that you're using to support your Vagrant installation. In my case, I'm selecting VirtualBox, which is probably going to be the most common choice that you're going to make. However, if you're using a different provider, you will need to both select a different provider here and before starting the virtual environment, edit the Homestead.yml file and ensure that the provider option in that file matches the one you selected. The command here should download and install a Vagrant box that Laravel provides, Homestead. In my case, since I already have it installed, I didn't need to download and install it. At this point, we can install Laravel onto our computers. To do this, we'll need one final piece of software. We'll need a tool called Composer. Composer is a really common tool in the PHP world for managing dependencies of a project. If you don't have Composer already installed, you can go back to your web browser and go to Getcomposer.org. From there, there is a Download button and it'll give you code to run in your Terminal application to install Composer locally. You'll note here that you'll need to have a PHP version installed to install Composer. After you have Composer set up, we'll go back to our Terminal application and we'll now run the command to install and set up our Homestead box and our Laravel project. That command is going to be, composer create-project - -prefer-dist laravel/laravel and then we'll name our project. In my case, I'm going to name the project laravel-essentials. Once you see that your application key was set successfully, you'll want to go into the directory laravel-essentials. We can do this with cd laravel-essentials. Cd stands for change directory. We'll now want to run the command, composer require laravel/homestead - -dev. At this point, we can now run the command to make our Homestead file. If you're on Windows, the command to make the Homestead file is vendor\\bin\\homestead make. This is the command if you're on Windows again. If, however, you're on a Mac, the command is php vendor/bin/homestead make. In the course of trying to setup Homestead, if you get a report back that the path to the private key cannot be found, you'll want to run the command ssh-keygen - t rsa -f ~/.ssh/id_rsa. This command is going to generate a unique and new private key pair for yourself. After you do this, that error will go away and you can run Vagrant up just like you expected. At this point, you should be able to run the command, vagrant up, to boot your Vagrant box. Once your Vagrant box has been booted, you can get into the box with the command, vagrant ssh. And from here, you'll be able to see your code inside of your Homestead box at change directory, again, cd code. Here's where we're going to be running a lot of commands, so you should get fairly familiar with running the command, vagrant up and vagrant ssh. Let's verify in our browser that we can see the Laravel homepage. We'll go to our browser, we'll open up a new tab, and we'll go to Homestead.test. If when you try opening up Homestead.test, you get the page that you cannot open Homestead.test, you'll want to take a look in the Laravel docs for Homestead. In there, there's this section on Per Project Installation. This is the instructions that we're following now. Under there, there's an entry to be able to set up in your etc/hosts file entry for Homestead.test. To do that, you'll want to edit your etc/hosts file. In my case, that means I'll run the command, sudo nano etc/hosts. And I'll add the line, 192.168.10.10 homestead.test. And after I've written that out and saved it and gone back to my browser and refreshed the page, I now see my Homestead.test homepage.
- Exploring Laravel
- Setting up simple authentication
- Controllers and routes
- Create and index view
- Show, edit, and destroy views
- Writing scopes in Laravel Eloquent
- Creating one-to-one relationships