Lessons: 21Length: 2.4 hours

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

1.2 Set Up Your Environment

Of course the first thing that we need to go over is what you need to set up your environment for not just Laravel development but just PHP development in general. And we're going to start with what I personally use, it's called XAMPP. Now one of the things about PHP is that in order to develop it, you have to download and install PHP. You have to have a database engine. Well, not really, but if you're going to build anything worthwhile, you need the database engine. It also helps to have a web server like Apache. So you have to download and install, and configure all of those things manually. And if you like doing that, then feel free to do so. I don't, and something like XAMPP gives you all of those things out of the box. They're configured. You can even turn on and off the services, and that's what I really like about something like this. Because I don't always want those services running, so I can start whichever ones that I need. And then I can turn them off whenever I'm done. So if that's the way that you want to go, feel free to download and install XAMPP. There are of course versions for Windows, Linux and Mac OS. There's also sub versions with different PHP versions. Now if you don't want to use XAMPP but you like the idea of using something like XAMPP. There's also something called MAMP, and there's nothing wrong with MAMP. I used to use MAMP before I went to XAMPP. And the only reason why I did is because at the time, they didn't support the version of PHP that I needed. And this page is Windows-centric. However, behind the scenes, they are detecting that I'm on Windows and they are always showing me Windows, which kind of stinks. I would like to see other platforms that are supported but they do support Mac OS. They might support Linux. I don't really remember if they do or not, but that is another option. You install it, they configure everything, you turn on and off the services whenever you want. Now if you want a more manual approach, but you don't want to go to the individual websites and download, and install, and you're on Mac OS. Then homebrew is going to be your option. The website is brew.sh and simply search for the packages that you want to download and install onto your machine. There is of course PHP. If you wanted to install MySQL, just do a search for that. And we'll find the command for installing that as well. And then finally, Laravel makes several tools available. In fact, they give you a Docker image that you can use. Now, if you're not familiar with Docker, it's not a virtual machine. It's more like a virtual operating system so that you can run applications. It's a really cool technology. And I really like this type of approach because it completely separates your development environment from your main environment. Which is a practice that I've gotten into personally just because I hate redoing my development environment when I set up a new machine. But if you go to the documentation and go to the installation, you're going to see your first Laravel project. And then you're going to see the getting started for whatever operating system that you are on. It's going to take you through the steps of using Docker. Now unfortunately we're not going to take this route in this course. It's a really awesome way of setting up an environment. However, my Docker installation is hosed after I upgraded it. But if you wanted to take this route, then feel free to do so. The instructions are very clear, just follow them and you will be good to go. So in our case, what we want to do is install Laravel with Composer. Now if you don't have Composer, this is a package manager for PHP. I believe the website is GetComposer, but if you just do a search for composer, there it is, getcomposer.org. Download and install it on your machine. And then from there, you'll want to open up a command line so that you can install the Laravel installer. Now there is the option to not install the Laravel installer, and just run it off of the web. However, I personally like to install the installer so that well, it just speeds things up. So from the command line, after you install Composer, you will want to type composer global require Laravel/installer. And then this is going to install the Laravel installer on your machine so that whenever it's done, then we can create a new application by using the Laravel command. We will follow that up with new. And then we will name our project. I'll just call this first-app. This is going to install our application. It's going to set everything up so that whenever this is done, we can CD into that directory, fire up our code editor. We can even fire up the application itself and we will see it up and running. When the installer is done then we will of course want to CD into first-app. We can go ahead and fire up our code editor but most important, we can run our application using Artisan, which is a command line interface for Laravel. And we'll say php artisan serve, that will run our application and it tells us where to go. So let's hop on over to the browser, we want to go to localhost port 8000. And we will see our application, there's not gonna be a whole lot there. But we can at least see that it is up and running, and in the next lesson, we will see how this page is processed and sent to the browser.

Back to the top