Laravel Installation
LaravelLaravel is the most popular PHP framework. It provides tools for routing, database management, authentication, and much more — out of the box.
Requirements
| Requirement | Version |
|---|---|
| PHP | 8.2+ |
| Composer | Latest |
| MySQL / PostgreSQL | Any recent version |
Install Laravel
Terminal
# Install Composer first: https://getcomposer.org
# Create new Laravel project
composer create-project laravel/laravel myapp
# Or use Laravel installer
composer global require laravel/installer
laravel new myapp
# Start development server
cd myapp
php artisan serve
# Server running at: http://127.0.0.1:8000Directory Structure
Structure
myapp/
├── app/
│ ├── Http/
│ │ ├── Controllers/ ← Your controllers
│ │ └── Middleware/ ← Middleware
│ └── Models/ ← Eloquent models
├── config/ ← Configuration files
├── database/
│ ├── migrations/ ← Database migrations
│ └── seeders/ ← Test data
├── public/ ← Web root (index.php)
├── resources/
│ └── views/ ← Blade templates
├── routes/
│ ├── web.php ← Web routes
│ └── api.php ← API routes
├── storage/ ← Logs, cache, uploads
├── tests/ ← Tests
└── .env ← Environment configThe .env File
.env
APP_NAME=MyApp
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=fileArtisan CLI
Terminal
# List all artisan commands
php artisan list
# Start dev server
php artisan serve
# Create things
php artisan make:controller UserController
php artisan make:model Post -m # model + migration
php artisan make:middleware AuthCheck
# Database
php artisan migrate
php artisan migrate:rollback
php artisan db:seed
# Cache
php artisan cache:clear
php artisan config:clear💡
Never commit .env to Git! It contains sensitive passwords. Laravel's
.gitignore excludes it automatically. Use .env.example to share the structure.Test your knowledge!
Take a quiz to reinforce what you learned.