Running your first laravel project

Table of contents
🛠️ How to Create & Run Your First Laravel Project (Step-by-Step Guide)
✅ Step 1: Install Laravel
⚠️ You must have Composer and PHP (8.1 or higher) already installed.
If not installed:
Composer: https://getcomposer.org/
You can check using:
php -v
composer -v
✅ Step 2: Create Your First Project
Open Command Prompt or Terminal, then run:
laravel new my-app
my-app
is your project name. You can use any name, e.g.,laravel-blog
,my-store
, etc.This command downloads Laravel and sets up the whole folder structure.
If laravel
command doesn’t work, install Laravel globally:
composer global require laravel/installer
or
composer create-project --prefer-dist laravel/laravel project-name
🔄 It might ask for:
Database: choose
MySQL
Testing: choose
Pest
orPHPUnit
Frontend stack: pick whatever is recommended or skip for now
✅ Step 3: Open Project in VS Code
Go to the folder:
cd my-app
Now open it in VS Code: The below command will open your current project in VS code
code .
✅ Step 4: Run the Project
In the VS Code open terminal or any command prompt, run:
php artisan serve
✅ This will start a development server at:
http://127.0.0.1:8000
Open that URL in your browser. You will see the Laravel welcome page.
✅ Step 5: How is the Welcome Page Working?
Here’s how Laravel connects everything:
🧩 routes/web.php
This file contains route definitions.
Default route looks like:
Route::get('/', function () {
return view('welcome');
});
/
means homepage.It means that whenever you write “/” in your url and enter it will return you the page mentioned in this view('welcome').
It returns the view called
welcome
.
🧩 resources/views/welcome.blade.php
This is the HTML file you see in the browser. You can edit this file and refresh the browser to see changes.
📁 File Structure (Relevant for First Project)
File/Folder | Purpose |
routes/web.php | Where you define website routes |
resources/views/ | Where you create HTML-like files (.blade.php ) |
app/Http/Controllers/ | Where you will write your logic (later) |
.env | Store DB connection, app URL, keys etc |
php artisan serve | Command to run Laravel app |
🧪 Example:
Let’s say you want to make a new page called about
.
Create a new file:
resources/views/about.blade.php
<!DOCTYPE html> <html> <head><title>About Page</title></head> <body> <h1>About Laravel Project</h1> </body> </html>
Add this in
web.php
:
Route::get('/about', function () {
return view('about');
});
- Now open your browser and visit:
👉http://127.0.0.1:8000/about
You'll see your new page!
🔚 Summary
Step | What You Do |
1️⃣ | Install Laravel |
2️⃣ | Create Project (laravel new my-app ) |
3️⃣ | Open in VS Code |
4️⃣ | Run with php artisan serve |
5️⃣ | Visit localhost:8000 to see welcome page |
6️⃣ | Learn routing, views, and customize your pages |
Subscribe to my newsletter
Read articles from Nature directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
