Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:9Length:41 minutes

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

1.2 Preparing the Development Environment

Before we can begin building our Laravel website, we need to prepare a development environment. First, we’ll have to download and install Laravel using the Composer tool. Then, we’ll set up our dev environment by using Laravel’s built-in Artisan utility.

Related Links

1.2 Preparing the Development Environment

Before we can even jump into any code, we need to prepare the environment. For this course, we're simply going to be using Laravel's built-in serve function, which is basically a nice wrapper for the native PHP server. Once you start developing more complex projects, I'd recommend that you move on to using a Vagrant machine. And for the box, I'd recommend you use Homestead, which is the official Vagrant box for Laravel. So the first thing I'm going to do is open up a new terminal. Now if you're not very comfortable in the terminal, I strongly recommend that you learn some of the basics, as understanding how to set up a simple environment like this is extremely handy knowledge for any developer. Now in our terminal, we'll make a new directory called LaravelWebsite, and then we'll use the cd command to navigate to it. This is the directory where we're going to be installing our Laravel project. To install Laravel, we're going to make use of Composer. Now if you don't have Composer installed or don't know much about it, then simply head over to getcomposer.org and follow the instructions on the Getting Started page to install it. Composer is one of the most essential tools to any PHP developer's toolkit. Once you've got Composer installed, either locally or globally, we can run composer create-project laravel/laravel, with dot as the directory we wish to install it in, and this period refers to the current working directory. The create-project demand will create a new Laravel project in our current working directory. It will then pull down all of the required dependencies for a fresh Laravel installation. This is basically a shortcut for running git-clone of the Laravel repository and then running Composer install. So this command will take several minutes to run if you've never run it before or if you haven't run it recently, as none of the dependencies will be cached. So once the command is done, we're practically ready to begin coding. For this course, we're not going to be going through the steps of setting up Homestead or using Vagrant or some other environment. Instead, we're quickly going to whip up a PHP server by running php artisan serve. This is one of the handier Artisan commands. What it does is fires up a local PHP server and makes it available on localhost:8000. If you'd like, you can pass in a different port by using the port option, and then pass in the port number, such as 8080. Right, so now if we fire up our web browser and navigate to localhost:8080, we'll be presented with the Laravel splash page, which means that we have successfully installed Laravel and we're ready to begin building our first web site. Before we begin our next lesson, let's just open up our project in Sublime so we can get started with the editing. I'm going to be doing this from my terminal. All I need to do is run the subl command, which is short for sublime, and then I'll pass in a period as the first argument. This will open up a new Sublime window with the current working directory already open. I'm now ready to begin coding my website.

Back to the top