Getting Started with Laravel 11: A Step-by-Step Guide

2025-07-02• 4 min read• Backend
laravelphpgetting started
Getting Started with Laravel 11: A Step-by-Step Guide

Kickstart your Laravel 11 journey with this beginner-friendly guide to installation, configuration, and setup.

## Introduction

Laravel 11 is a powerful and elegant PHP framework built to make web development faster and cleaner. Whether you're building a personal project or an enterprise-level app, Laravel provides a rich set of tools to speed up development.

In this guide, you'll learn how to set up Laravel 11 from scratch, run your first app, and understand the basic file structure and flow of a Laravel project.

---

## Step 1: Install Laravel

Before starting, make sure you have Composer installed globally. Composer is a PHP package manager used to install Laravel and its dependencies.

To create a new Laravel 11 project, run:

```bash
composer create-project laravel/laravel:^11.0 my-app
```

This command creates a new Laravel project in the `my-app` directory.

> ✅ **Tip:** Laravel 11 requires PHP 8.2+.

---

## Step 2: Serve the App

Navigate into your newly created project directory:

```bash
cd my-app
```

Now start the development server:

```bash
php artisan serve
```

Visit [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser — you should see Laravel’s default welcome page.

---

## Step 3: Set Up Environment Configuration

Open the `.env` file — this contains all your app's environment-specific settings.

For example, to configure your database connection:

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp_db
DB_USERNAME=root
DB_PASSWORD=
```

Run migrations to prepare the default tables:

```bash
php artisan migrate
```

---

## Step 4: Understand the Folder Structure

Laravel has a clean and intuitive structure:

- `app/`: Contains your core app logic (models, controllers).
- `routes/web.php`: Define your web routes here.
- `resources/views/`: Blade templates go here.
- `database/migrations/`: DB schema definitions.
- `public/`: Web-accessible directory.

Understanding this layout early will help you navigate and scale your project smoothly.

---

## Step 5: Create Your First Route

Let’s edit the default route in `routes/web.php`:

```php
Route::get('/', function () {
    return view('welcome');
});
```

To return custom content:

```php
Route::get('/hello', function () {
    return 'Hello, Laravel 11!';
});
```

Visit [http://127.0.0.1:8000/hello](http://127.0.0.1:8000/hello) — you should see your custom message.

---

## Step 6: Generate a Controller

You can create a controller to handle business logic using Artisan:

```bash
php artisan make:controller HomeController
```

This creates `app/Http/Controllers/HomeController.php`.

Edit it like so:

```php
public function index()
{
    return view('home');
}
```

Then register it in your routes:

```php
Route::get('/home', [HomeController::class, 'index']);
```

---

## Step 7: Blade Templates

Create a new view file:

```
resources/views/home.blade.php
```

Add some HTML:

```blade
<!DOCTYPE html>
<html>
<head>
    <title>My First Page</title>
</head>
<body>
    <h1>Welcome to Laravel 11!</h1>
</body>
</html>
```

Blade is Laravel's templating engine and supports conditionals, loops, and includes.

---

## Step 8: What's Next?

Now that you're up and running, here are some next steps:

- Learn about **Eloquent** ORM for working with databases.
- Use **middleware** to protect routes.
- Add **authentication** using Laravel Breeze or Jetstream.
- Try building a simple CRUD app.
- Explore **queues**, **events**, and **notifications**.

---

## Conclusion

You’ve just created and configured a Laravel 11 application, set up your first route, created a controller, and built a basic view.

Laravel's learning curve is smooth, and the ecosystem is incredibly rich. Stick with it, build real things, and you’ll master backend development in no time.

> ⭐ Bonus tip: Follow Laravel News and the official docs to stay updated.

Happy coding! 🚀