How to Setup Laravel Project After Cloned from Git

In this tutorial you will learn how to setup Laravel project after cloning from Github or Gitlab or Bitbucket. Cloning a project/app is very easy and setup in our local matchin very simple.

In addition to cloning the repo, this means we need to setup the database, the env file, the encryption key, and more. Let’s start to clone a git repository in your system and setup the project easy way step by step here.

Step 1: Copy GitHub Repo

First at all login your git and go to the repository which you need to clone, after that click the code buttong copy the url just like below.

https://github.com/codingdriver15/LaravelAjaxCrud.git

Step 2: cd into your project

Now, open your project in terminal go inside the inside the www directory.

cd /var/wwww

After that paste the above git url and paste it

Step 3: Install Composer Dependencies

After successfully clonded now run the run composer install command

cd LaravelAjaxCrud
composer install

Step 4: Install NPM Dependencies

Now we must also install necessary NPM packages to move forward. This will install Vue.js, Bootstrap.css, Lodash, and Laravel Mix. So copy the below command and rurn inside the project.

npm install

If you are using ubuntu you must need to add sudo before the command.

Step 5: Create a copy of your .env file

After composer installation create .env file in your project root folder & copy everything from .env.example file into .env file.

DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

Step 6: Generate an app encryption key

After setup the .env file and update the database credentials you need run php artisan key:generate command in your terminal. it will generate APP_KEY in .env file for you.

php artisan key:generate

Step 7: Setup the Database

Then setup your DB_DATABASE, DB_USERNAME & DB_PASSWORD in .env file. Once your credentials are in the .env file. Now run the migrate command to generate the database tables.

php artisan migrate

Step 8: Seed the database (optional)

If the cloned project have seeder files then you need to run database seeder files just running the below command.

php artisan db:seed

After the migrations are complete and you have the database structure required, then you can seed the database.

After setup all the above things, now run php artisan serve in your terminal. it will run your project in your localhost at port 8000 by default. you can run project in any port you want by using port flag.

php artisan serve 
or
php artisan serve — port=8080

Hope you enjoy with setup a github project to local computer. If you have questions or queries feel free to contact us or drop a comment below.

Leave a Comment