Master Laravel development with real project examples and professional multi-project workflows. From setup to deployment and everything in between.

4
Real Projects
18
Comprehensive Steps
30+
Code Examples
5
Project Modules

Overview & Prerequisites

This comprehensive guide takes you through building real Laravel applications while managing multiple projects efficiently. You'll learn professional workflows used in development teams and solo projects alike.

What You'll Build

🛒 E-commerce Platform

Complete online store with products, cart, checkout, and payment integration.

  • Product catalog with categories
  • Shopping cart & wishlist
  • Payment gateway integration
  • Order management system
  • Customer reviews & ratings
Stripe API Livewire MySQL

📝 Blog CMS

Content management system with advanced features for writers and editors.

  • Multi-user roles & permissions
  • Rich text editor
  • Media library management
  • SEO optimization tools
  • Comment system
TinyMCE Spatie Permissions Redis

Task Management

Project management application with teams, assignments, and progress tracking.

  • Team collaboration
  • Real-time updates
  • File attachments
  • Progress analytics
  • Calendar integration
WebSockets Vue.js Laravel Echo

🔗 API Backend

RESTful API for mobile applications with authentication and documentation.

  • JWT Authentication
  • API rate limiting
  • Swagger documentation
  • Webhook support
  • Mobile optimization
Sanctum L5-Swagger Postman

Prerequisites

Basic knowledge of PHP, HTML, CSS, and JavaScript. Familiarity with command line usage. No prior Laravel experience required.

Important Notes

This guide assumes you're using Laravel 10.x. Code examples may need adjustments for older versions. Always test in a development environment before deploying to production.

1 Development Environment Setup Beginner

1

Choose Your Stack

Select a development environment that matches your operating system:

Tool Windows macOS Linux
Local Server Laragon (Recommended) Laravel Valet Laravel Homestead
Package Manager Composer for Windows Homebrew + Composer APT + Composer
Node.js Node.js Installer Homebrew or Node Installer NodeSource Repository
Code Editor VS Code with PHP Intelephense, Laravel Idea
2

Install Laragon (Windows)

Laragon provides the quickest setup for Windows users and is perfect for multi-project development:

# Download from laragon.org and install

After installation, start Laragon and click "Start All". Your environment is ready!

Laragon Features for Multi-Project

  • Automatic virtual hosts (yourproject.test)
  • Database management (MySQL, PostgreSQL)
  • Multiple PHP version support
  • Quick project creation wizard
  • Mailhog for email testing
  • Redis server included
3

Verify Installation

Check that all components are working correctly:

Terminal
php --version
composer --version
node --version
npm --version

2 Real Project Examples & Code Intermediate

E-commerce Platform Structure

Let's examine the complete structure of our e-commerce application:

app/
Models/
Product.php
Category.php
Order.php
Cart.php
Http/
Controllers/
ProductController.php
CartController.php
CheckoutController.php
Services/
PaymentService.php
InventoryService.php
database/
migrations/
2023_01_01_create_products_table.php
2023_01_02_create_orders_table.php

Product Model with Advanced Features

PHP
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class Product extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'description', 
        'price',
        'stock_quantity',
        'category_id',
        'sku',
        'images',
        'is_active',
        'featured'
    ];

    protected $casts = [
        'price' => 'decimal:2',
        'images' => 'array',
        'is_active' => 'boolean',
        'featured' => 'boolean'
    ];

    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }

    public function orders(): BelongsToMany
    {
        return $this->belongsToMany(Order::class)
            ->withPivot('quantity', 'unit_price')
            ->withTimestamps();
    }

    public function scopeActive($query)
    {
        return $query->where('is_active', true);
    }

    public function scopeFeatured($query)
    {
        return $query->where('featured', true);
    }

    public function scopeInCategory($query, $categoryId)
    {
        return $query->where('category_id', $categoryId);
    }

    public function getFormattedPriceAttribute(): string
    {
        return '$' . number_format($this->price, 2);
    }

    public function hasStock(int $quantity = 1): bool
    {
        return $this->stock_quantity >= $quantity;
    }

    public function decreaseStock(int $quantity = 1): bool
    {
        if (!$this->hasStock($quantity)) {
            return false;
        }

        $this->decrement('stock_quantity', $quantity);
        return true;
    }
}

Product Controller with CRUD Operations

PHP
<?php

namespace App\Http\Controllers;

use App\Models\Product;
use App\Models\Category;
use Illuminate\Http\Request;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
use Illuminate\Support\Facades\Storage;

class ProductController extends Controller
{
    public function index(): View
    {
        $products = Product::with('category')
            ->active()
            ->latest()
            ->filter(request(['search', 'category']))
            ->paginate(12);

        $categories = Category::all();

        return view('products.index', compact('products', 'categories'));
    }

    public function create(): View
    {
        $categories = Category::all();
        return view('products.create', compact('categories'));
    }

    public function store(Request $request): RedirectResponse
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'description' => 'required|string',
            'price' => 'required|numeric|min:0',
            'stock_quantity' => 'required|integer|min:0',
            'category_id' => 'required|exists:categories,id',
            'sku' => 'required|unique:products,sku',
            'images.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048'
        ]);

        if ($request->hasFile('images')) {
            $imagePaths = [];
            foreach ($request->file('images') as $image) {
                $path = $image->store('products', 'public');
                $imagePaths[] = $path;
            }
            $validated['images'] = $imagePaths;
        }

        Product::create($validated);

        return redirect()->route('products.index')
            ->with('success', 'Product created successfully.');
    }

    public function show(Product $product): View
    {
        $relatedProducts = Product::where('category_id', $product->category_id)
            ->where('id', '!=', $product->id)
            ->active()
            ->limit(4)
            ->get();

        return view('products.show', compact('product', 'relatedProducts'));
    }

    public function edit(Product $product): View
    {
        $categories = Category::all();
        return view('products.edit', compact('product', 'categories'));
    }

    public function update(Request $request, Product $product): RedirectResponse
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'description' => 'required|string',
            'price' => 'required|numeric|min:0',
            'stock_quantity' => 'required|integer|min:0',
            'category_id' => 'required|exists:categories,id',
            'sku' => 'required|unique:products,sku,' . $product->id,
            'images.*' => 'image|mimes:jpeg,png,jpg,gif|max:2048'
        ]);

        if ($request->hasFile('images')) {
            // Delete old images
            if ($product->images) {
                foreach ($product->images as $oldImage) {
                    Storage::disk('public')->delete($oldImage);
                }
            }

            $imagePaths = [];
            foreach ($request->file('images') as $image) {
                $path = $image->store('products', 'public');
                $imagePaths[] = $path;
            }
            $validated['images'] = $imagePaths;
        }

        $product->update($validated);

        return redirect()->route('products.index')
            ->with('success', 'Product updated successfully.');
    }

    public function destroy(Product $product): RedirectResponse
    {
        // Delete associated images
        if ($product->images) {
            foreach ($product->images as $image) {
                Storage::disk('public')->delete($image);
            }
        }

        $product->delete();

        return redirect()->route('products.index')
            ->with('success', 'Product deleted successfully.');
    }
}

3 Multi-Project Management Intermediate

Organizing Multiple Laravel Projects

Professional developers often work on multiple projects simultaneously. Here's how to set up an efficient multi-project environment:

1

Folder Structure Strategy

Organize your projects in a logical folder structure:

C:/
laragon/
www/
ecommerce-app/
blog-cms/
task-manager/
api-backend/

Best Practices

  • Use descriptive, consistent naming
  • Group related projects in subfolders
  • Keep client projects separate from personal projects
  • Maintain a consistent structure across all projects
2

Virtual Hosts Configuration

Laragon automatically creates virtual hosts for each project:

Project Local URL Database
E-commerce App http://ecommerce-app.test ecommerce_db
Blog CMS http://blog-cms.test blog_cms_db
Task Manager http://task-manager.test task_manager_db
API Backend http://api-backend.test api_backend_db
3

Environment Configuration

Each project needs its own environment configuration:

.env (E-commerce)
APP_NAME="E-commerce Store"
APP_ENV=local
APP_URL=http://ecommerce-app.test

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=ecommerce_db
DB_USERNAME=root
DB_PASSWORD=

STRIPE_KEY=sk_test_...
STRIPE_SECRET=sk_test_...
.env (Blog CMS)
APP_NAME="Blog CMS"
APP_ENV=local  
APP_URL=http://blog-cms.test

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=blog_cms_db
DB_USERNAME=root
DB_PASSWORD=

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025

Switching Between Projects

1

Quick Project Switching

Use Laragon's quick menu to switch between projects instantly:

# Right-click Laragon tray icon → www → Select project

This opens the project in your browser and focuses the folder in your file explorer.

2

VS Code Workspace Setup

Create a workspace file to manage all your projects in VS Code:

laravel-projects.code-workspace
{
    "folders": [
        {
            "name": "E-commerce App",
            "path": "C:/laragon/www/ecommerce-app"
        },
        {
            "name": "Blog CMS", 
            "path": "C:/laragon/www/blog-cms"
        },
        {
            "name": "Task Manager",
            "path": "C:/laragon/www/task-manager"
        },
        {
            "name": "API Backend",
            "path": "C:/laragon/www/api-backend"
        }
    ],
    "settings": {
        "php.validate.executablePath": "C:/laragon/bin/php/php-8.2.0/php.exe",
        "laravel-ide-helper.includeClassNamespaces": [
            "App", "Illuminate", "Database"
        ]
    }
}
3

Database Management

Use Laragon's database tools to manage all your project databases:

# Laragon → Menu → MySQL → Admin (phpMyAdmin)

Or use the command line for quick operations:

Terminal
# Switch to ecommerce project
cd C:\laragon\www\ecommerce-app

# Run migrations
php artisan migrate

# Switch to blog project  
cd C:\laragon\www\blog-cms

# Run seeders
php artisan db:seed

Pro Tips for Multi-Project Development

  • Use consistent .env patterns across all projects
  • Create project-specific database users for better security
  • Set up Git branches for feature development
  • Use Docker containers for complex dependency requirements
  • Maintain a shared utilities package for common functionality

18 Resources & Next Steps

Community Resources

  • Laravel News Newsletter
  • Laravel Discord Community
  • Laravel Reddit Community
  • Local Laravel Meetups

Next Steps

Continue your Laravel journey by exploring:

  • Laravel Livewire for dynamic interfaces
  • Laravel Nova for admin panels
  • Laravel Echo for real-time features
  • Laravel Sanctum for SPA authentication
  • Laravel Dusk for browser testing