🎯 Learning Objectives
- Understand what Laravel is and why it's popular
- Learn MVC (Model-View-Controller) architecture
- Install Composer dependency manager
- Create your first Laravel project
- Run Laravel development server
🔥 What is Laravel?
Laravel is the most popular PHP framework for building modern web applications. It provides elegant syntax, powerful tools, and follows the MVC architecture pattern.
Created by: Taylor Otwell in 2011
Current Version: Laravel 11 (as of 2024)
✨ Why Use Laravel?
🎨 Elegant Syntax
Clean, expressive code that's easy to read and write
🗄️ Eloquent ORM
Powerful database abstraction for working with data
🔐 Built-in Security
Protection against SQL injection, XSS, CSRF attacks
📝 Blade Templates
Powerful templating engine for dynamic views
🚀 Fast Development
Built-in tools speed up common tasks
📚 Great Documentation
Comprehensive docs and large community
🏗️ Understanding MVC Architecture
| Component | Purpose | Laravel Location |
|---|---|---|
| Model | Handles data and business logic | app/Models/ |
| View | Displays data (HTML/Blade templates) | resources/views/ |
| Controller | Handles requests and coordinates Model-View | app/Http/Controllers/ |
📦 Step 1: Install Composer
Composer is a dependency manager for PHP. It allows you to install Laravel and its required packages.
Windows Installation:
- Visit: https://getcomposer.org/download/
- Download Composer-Setup.exe
- Run the installer and follow the steps
- Make sure to select the PHP executable (usually in XAMPP:
C:\xampp\php\php.exe) - Click "Install" and wait for completion
Verify Composer Installation:
🚀 Step 2: Install Laravel
Option 1: Install Laravel Installer (Recommended)
Option 2: Create Project Directly with Composer
🎉 Step 3: Create Your First Laravel Project
Using Laravel Installer:
Using Composer:
🌐 Step 4: Run Laravel Development Server
View Your Laravel Application:
- Open your browser
- Go to:
http://127.0.0.1:8000orhttp://localhost:8000 - You should see the Laravel welcome page! 🎉
📁 Laravel Project Structure (Quick Overview)
🛠️ Useful Artisan Commands
| Command | Purpose |
|---|---|
php artisan serve |
Start development server |
php artisan --version |
Check Laravel version |
php artisan list |
List all available commands |
php artisan make:controller |
Create a new controller |
php artisan make:model |
Create a new model |
php artisan migrate |
Run database migrations |
💻 Test Your Installation
❗ Common Installation Issues
| Issue | Solution |
|---|---|
| Composer not found | Restart terminal after installation or add to PATH |
| PHP version too old | Update XAMPP to latest version (PHP 8.1+) |
| Port 8000 in use | Use different port: php artisan serve --port=8080 |
| Permission errors | Run terminal as Administrator |
🔧 Enable Required PHP Extensions
Open C:\xampp\php\php.ini and uncomment (remove semicolon):
Note: Restart Apache after making changes.
✏️ Practice Exercises
- Install Composer on your system
- Create a new Laravel project called "blog-app"
- Run the development server
- Take a screenshot of the Laravel welcome page
- Run
php artisan listand explore available commands
✅ Today's Deliverable
- ✓ Composer installed and verified
- ✓ Laravel project created ("student-management")
- ✓ Development server running successfully
- ✓ Laravel welcome page displaying in browser
- ✓ Screenshot of working Laravel installation