DEV Community

Cover image for How to Set Up a Laravel Project on Localhost After Cloning From Git
Chirag Patel
Chirag Patel

Posted on

How to Set Up a Laravel Project on Localhost After Cloning From Git

So you just cloned a Laravel project from GitHub, but the app isn’t working on your local system?
Don’t worry — you're not alone. Every Laravel developer goes through this the first time.

In this guide, we’ll walk through step-by-step how to set up a Laravel project locally after git clone.
This works on Windows, macOS, and Linux.

✅ Beginner-friendly
✅ Copy-paste ready commands


1. Clone the Laravel Project

Open your terminal and clone the repo:

git clone https://github.com/your-username/your-laravel-project.git
cd your-laravel-project
Enter fullscreen mode Exit fullscreen mode

2. Install PHP Dependencies

Laravel uses Composer to manage PHP packages. Run:

composer install
Enter fullscreen mode Exit fullscreen mode

If you see composer command not found, install it first: Composer Install

3. Create .env File

Copy the sample environment file:

cp .env.example .env
Enter fullscreen mode Exit fullscreen mode

Windows users:

copy .env.example .env
Enter fullscreen mode Exit fullscreen mode

Now open .env and update:

  • Database name
  • Database username
  • Password

Example:

DB_DATABASE=laravel_app
DB_USERNAME=root
DB_PASSWORD=
Enter fullscreen mode Exit fullscreen mode

4. Generate Application Key

php artisan key:generate
Enter fullscreen mode Exit fullscreen mode

This secures your session & app data.

5. Run Database Migrations (If applicable)

php artisan migrate
Enter fullscreen mode Exit fullscreen mode

If you see database errors, make sure the DB exists. Create it manually or via command (MySQL):

CREATE DATABASE laravel_app;
Enter fullscreen mode Exit fullscreen mode

6. Link Storage (For uploads & images)

php artisan storage:link
Enter fullscreen mode Exit fullscreen mode

7. Install Node Dependencies (If project has frontend)

npm install
npm run dev  # or npm run build for production
Enter fullscreen mode Exit fullscreen mode

8. Serve the Project

Start Laravel local server:

php artisan serve
Enter fullscreen mode Exit fullscreen mode

Open in browser:

http://127.0.0.1:8000
Enter fullscreen mode Exit fullscreen mode

🎉 Your Laravel app is running!


🧠 Common Errors & Fixes

Error Quick Fix
Class not found Run composer dump-autoload
.env file not loading Delete cache: php artisan config:clear
500 error after migration Check DB credentials & run php artisan migrate:fresh
npm not found Install Node.js: https://nodejs.org/

✅ Final Checklist

Task Status
Clone project
Install composer deps
Setup .env
Generate key
Run migrations
Install npm
Run server

🎯 Conclusion

Setting up a Laravel project locally after cloning is simple once you know the process:

Task Command
Clone project git clone 'link projer github'
Install composer deps composer install
Setup .env cp .env.example .env or copy .env.example .env
Configure DB Now open .env and update: Database name, Database username, Password
Generate key php artisan key:generate
Run migrations php artisan migrate
Install npm(optional) npm install
Run server php artisan serve

Bookmark this guide — it will save you time on every project!


💬 Have Questions?

Drop a comment — happy to help!
And if you found this useful, smash the ❤️ and follow for more Laravel tips.


🔁 Bonus: Full Setup Script (Linux/Mac)

git clone repo-url project
cd project
composer install
cp .env.example .env
php artisan key:generate
npm install && npm run dev
php artisan migrate
php artisan serve
Enter fullscreen mode Exit fullscreen mode

Top comments (0)