Getting almost any Laravel project up and running in your local machine
Tags: laravel, tutorial
Published: 2018-11-05 07:07:22

---
title: Getting almost any Laravel project up and running in your local machine
published: true
tags: Laravel, Tutorial
canonical_url: https://miguelpiedrafita.com/laravel-local-environment/
---

After writing this guide in three different documentation pages, I've decided to _abstract_ it to an article I can keep updated. Keep in mind this are general instructions, and you may have to follow some custom steps depending on what you're trying to run. With that said, here's what you need to do:

## Requirements

Before getting started, here are some thing you'll need:

- PHP7 - Learn how to install it in [Windows](https://www.jeffgeerling.com/blog/2018/installing-php-7-and-composer-on-windows-10), [Mac](https://medium.com/@romaninsh/install-php-7-2-xdebug-on-macos-high-sierra-with-homebrew-july-2018-d7968fe7e8b8) or [Linux](https://tecadmin.net/install-php-7-on-ubuntu/)
- Composer - Learn [how to install it](https://getcomposer.org/doc/00-intro.md)
- A terminal - Your OS should already come with one

## Get the code into your computer

Let's assume the project is hosted on GitHub (or GitLab, any git service should work). The preferred method would be to perform a git clone. You can do this by running the following in your terminal of choice:

```
git clone https://github.com/someuser/someproject
```

Of course, not everyone has or wants to use git, so almost all git services offer a way to download zipped version of the repository. Just search for a "_Download ZIP_" option. Then, you'll want to unzip it before proceeding to the next step.

## Installing dependencies

To light up the size of the repository, Laravel projects rarely bundle their dependencies with them. You'll need to use `composer` to download them. To do this, just open a terminal window on the repository folder and run the following:

```
composer install
```

This process may take between one and five minutes depending on the number of dependencies.

## Setting up the database

Most Laravel apps require a database. To keep it simple, we're gonna use a sqlite database, which is just a simple file and requires no external programs. To configure it, search for a `.env.example` file on the repository and rename it to `.env` . You'll also need to open the `database` folder and create an empty file called `database.sqlite` . After this, open your `.env` file in a text editor and make the following changes:

```diff
-DB_DRIVER=mysql
-DB_DATABASE=homestead
+DB_DRIVER=sqlite
+DB_DATABASE=database/database.sqlite
```

Finally, open up a terminal window and run the following command:

```
php artisan migrate
```

## Setting up the application key

Easy one! Just open up a terminal window, run the following and you're done!

```
php artisan key:generate
```

## Get a server running

You can use almost any server to serve your app but, to keep it simple, we're gonna use Laravel's integrated one. Open up a terminal window and run the following command:

```
php artisan serve
```

You should now be able to access your app by [using this link](http://localhost:8080).

## That's it!

If everything went right, you should now be watching the main page of your Laravel project. Congratulations and enjoy the power of Laravel!

_Liked this article? Consider [supporting my work](https://miguelpiedrafita.com/patreon)._