Project Structure
When you create a Laravel project, you get a well-organized directory structure. Let's break down each folder so you know exactly where things go.
Think of this as your roadmap โ knowing the structure saves you hours of confusion later.
The app/ Directory
This is where your application logic lives. Models, controllers, middleware, services โ all go here. The app/ directory follows PSR-4 autoloading, meaning the namespace matches the directory structure.
app/
โโโ Console/
โโโ Exceptions/
โโโ Http/
โ โโโ Controllers/
โ โโโ Middleware/
โ โโโ Kernel.php
โโโ Models/
โโโ Providers/
โโโ User.php
Your Models/ folder contains Eloquent models, Http/Controllers/ holds your controllers, and Providers/ manages service bindings.
Key Configuration Directories
The config/ directory contains all your configuration files as plain PHP arrays. Each file handles a specific concern โ database, cache, sessions, mail, and more. You rarely need to modify these directly, but it's good to know they're there.
config/
โโโ app.php
โโโ auth.php
โโโ database.php
โโโ cache.php
โโโ session.php
โโโ mail.php
The database/ directory holds your migrations, seeders, and factories. The public/ directory is your web root โ it contains index.php, which is the entry point for all requests.
resources/ and routes/
The resources/ directory stores your views, raw CSS, JavaScript, and language files. Blade templates go in resources/views/.
The routes/ directory is where you define all your application's routes. Laravel organizes them into separate files by type:
routes/
โโโ web.php
โโโ api.php
โโโ console.php
โโโ channels.php
The web.php file defines routes for your web interface, while api.php handles API endpoints. The artisan file at the project root is Laravel's command-line interface tool.