How to run a Laravel Project from GitHub?

I found a laravel project on GitHub but the problem is I am unable to run it. Can anyone help me set up the laravel project cloned from GitHub?

1. Clone GitHub project

Clone or download the project from GitHub. If you want to clone then make sure you have git installed on your computer. Else download and extract the project.

git clone <project>

2. Open the project folder

You need to open your project folder or cd into your project from the command line. It’s better you use the command line because the rest of the steps are in the command line.

cd <project-folder>

3. Install Laravel Dependencies

Make sure you have composer installed on your computer. In most cases, you will not get any dependencies along with the GitHub project. You need to install them after you clone the project from GitHub. Run the following command in the command line.

composer install

You will see composer will start installing the necessary files. You can see which dependencies are installed by opening composer.json

4. Install NPM Dependencies

This is not necessary that your project has npm dependencies but if it has then you need to install it as well. First, check if your project folder root has a package.json file. If it does then you may need to install the dependencies. Make sure you have NodeJs installed on your computer then run the following command.

npm install

5. Create a .env file

For security reasons, you will not get a .env file with the GitHub project. You need to create one from .env.example and fill up the necessary information. Use the following command to copy the .env file form .env.example

cp .env.example .env

Now update the database info or other details in the .env file. e.g. DB_HOST , DB_PORT , DB_DATABASE , DB_USERNAME , and DB_PASSWORD

6. Generate an app encryption key

Laravel requires an app encryption key which is used to encode cookies to password hashes and more. An encryption key is generally a randomly generated string stored in your .env file. To generate the app encryption key use the following command.

php artisan key:generate

7. Migrate the database

As you already update the database connection details in .env file you can now migrate the database with the following command.

php artisan migrate

8. Seed the database (optional)

If the project has a seeding file then you need to seed the data. This is normally to insert starter or dummy data into the database. If your project doesn’t have any seed file then don’t need to follow this step. Use the following command to seed your database.

php artisan db:seed

9. Run Laravel Development Server

All should be set by now. You can run laravel development server with the following command.

php artisan serve

Now visit the following link to see the project