📅 Week 13 - Day 1: Laravel Installation & Setup

Monday | Duration: 3 hours | Welcome to Laravel! 🚀

🎯 Learning Objectives

🔥 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/
User Request → Routes → Controller → Model (Database) → View (HTML) → Response

📦 Step 1: Install Composer

Composer is a dependency manager for PHP. It allows you to install Laravel and its required packages.

Windows Installation:

  1. Visit: https://getcomposer.org/download/
  2. Download Composer-Setup.exe
  3. Run the installer and follow the steps
  4. Make sure to select the PHP executable (usually in XAMPP: C:\xampp\php\php.exe)
  5. Click "Install" and wait for completion

Verify Composer Installation:

# Open PowerShell or Command Prompt composer --version # Expected output: # Composer version 2.x.x

🚀 Step 2: Install Laravel

Option 1: Install Laravel Installer (Recommended)

# Install Laravel globally composer global require laravel/installer # Verify installation laravel --version

Option 2: Create Project Directly with Composer

# Navigate to your projects directory cd C:\xampp\htdocs # Create new Laravel project composer create-project laravel/laravel my-first-app # This will take a few minutes to download and install

🎉 Step 3: Create Your First Laravel Project

Using Laravel Installer:

# Navigate to your directory cd C:\xampp\htdocs # Create new project laravel new student-management # Navigate into project cd student-management

Using Composer:

# Create project composer create-project laravel/laravel student-management # Navigate into project cd student-management

🌐 Step 4: Run Laravel Development Server

# Make sure you're in the project directory cd C:\xampp\htdocs\student-management # Start Laravel server php artisan serve # Expected output: # INFO Server running on [http://127.0.0.1:8000].

View Your Laravel Application:

  1. Open your browser
  2. Go to: http://127.0.0.1:8000 or http://localhost:8000
  3. You should see the Laravel welcome page! 🎉

📁 Laravel Project Structure (Quick Overview)

student-management/ │ ├── app/ # Application core │ ├── Http/ │ │ └── Controllers/ # Your controllers │ └── Models/ # Your models │ ├── config/ # Configuration files ├── database/ │ ├── migrations/ # Database migrations │ └── seeders/ # Database seeders │ ├── public/ # Publicly accessible files │ └── index.php # Entry point │ ├── resources/ │ └── views/ # Blade templates │ ├── routes/ │ └── web.php # Web routes │ ├── .env # Environment configuration └── artisan # Laravel command-line tool

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

# 1. Check PHP version (Laravel 10+ requires PHP 8.1+) php -v # 2. Check Composer version composer --version # 3. Check Laravel version cd C:\xampp\htdocs\student-management php artisan --version # 4. Start server php artisan serve # 5. Open browser: http://localhost:8000

❗ 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):

extension=fileinfo extension=mbstring extension=openssl extension=pdo_mysql extension=curl extension=gd

Note: Restart Apache after making changes.

✏️ Practice Exercises

  1. Install Composer on your system
  2. Create a new Laravel project called "blog-app"
  3. Run the development server
  4. Take a screenshot of the Laravel welcome page
  5. Run php artisan list and explore available commands

✅ Today's Deliverable

← Previous Week Course Home Next: Day 2 →