Running your first laravel project

NatureNature
3 min read


🛠️ 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:

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 or PHPUnit

  • 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/FolderPurpose
routes/web.phpWhere you define website routes
resources/views/Where you create HTML-like files (.blade.php)
app/Http/Controllers/Where you will write your logic (later)
.envStore DB connection, app URL, keys etc
php artisan serveCommand to run Laravel app

🧪 Example:

Let’s say you want to make a new page called about.

  1. 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>
    
  2. Add this in web.php:

Route::get('/about', function () {
    return view('about');
});
  1. Now open your browser and visit:
    👉 http://127.0.0.1:8000/about

You'll see your new page!


🔚 Summary

StepWhat 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

10
Subscribe to my newsletter

Read articles from Nature directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nature
Nature