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
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
Task Management
Project management application with teams, assignments, and progress tracking.
- Team collaboration
- Real-time updates
- File attachments
- Progress analytics
- Calendar integration
API Backend
RESTful API for mobile applications with authentication and documentation.
- JWT Authentication
- API rate limiting
- Swagger documentation
- Webhook support
- Mobile optimization
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
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 | ||
Install Laragon (Windows)
Laragon provides the quickest setup for Windows users and is perfect for multi-project development:
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
Verify Installation
Check that all components are working correctly:
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:
Product Model with Advanced Features
<?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
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:
Folder Structure Strategy
Organize your projects in a logical folder structure:
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
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 |
Environment Configuration
Each project needs its own environment configuration:
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_...
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
Quick Project Switching
Use Laragon's quick menu to switch between projects instantly:
This opens the project in your browser and focuses the folder in your file explorer.
VS Code Workspace Setup
Create a workspace file to manage all your projects in VS Code:
{
"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"
]
}
}
Database Management
Use Laragon's database tools to manage all your project databases:
Or use the command line for quick operations:
# 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
Official Documentation
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