Skip to main content
Laravel follows a conventional directory structure that organizes your application code, configuration, and resources. This page provides a complete overview of each directory and its purpose.

Root Directory

The root directory contains several important files and directories that form the foundation of your Laravel application.

Root Files

The Artisan command-line interface file. This is the entry point for running all Artisan commands.
php artisan serve
php artisan migrate
Defines your application’s PHP dependencies and autoloading configuration. This file is used by Composer to manage packages.
See the Composer Scripts page for available scripts.
Defines your application’s JavaScript dependencies and build scripts. Used by npm or yarn for frontend asset management.
Configuration file for PHPUnit testing framework. Defines test suites, environment variables, and coverage settings.
Configuration file for Vite, the modern frontend build tool used by Laravel for compiling and bundling assets.
Example environment configuration file. Copy this to .env and customize for your application.
Never commit your .env file to version control as it contains sensitive information.

Directory Structure

app/

The app directory contains the core code of your application. This is where most of your application’s classes will reside.
Contains controllers, middleware, and form requests. This directory handles the HTTP layer of your application.Subdirectories:
  • Controllers/ - Controller classes that handle incoming HTTP requests
  • Middleware/ - HTTP middleware for filtering requests
  • Requests/ - Form request validation classes
Contains Eloquent model classes that represent your database tables. Each model corresponds to a table in your database.Example:
  • User.php - The default user model for authentication
Service provider classes that bootstrap various components of your application.Default Providers:
  • AppServiceProvider.php - General application service provider
Contains custom Artisan commands (created when you generate commands).
Contains exception handling classes for your application (created when needed).

bootstrap/

The bootstrap directory contains the application bootstrapping files.
Contains framework generated files for performance optimization, including compiled services and package manifests.
This directory must be writable by your web server.

config/

The config directory contains all of your application’s configuration files.
  • app.php - Core application configuration (name, environment, timezone)
  • auth.php - Authentication guards and providers configuration
  • cache.php - Cache store configuration (Redis, Memcached, file, etc.)
  • database.php - Database connection configuration
  • filesystems.php - File storage configuration (local, S3, etc.)
  • logging.php - Logging channels and handlers configuration
  • mail.php - Email service configuration
  • queue.php - Queue connection configuration
  • services.php - Third-party service credentials
  • session.php - Session storage and behavior configuration
Configuration values can reference environment variables using the env() helper function.

database/

The database directory contains database-related files.
Contains model factory classes for generating fake data during testing and seeding.
Contains database migration files that define your database schema. Migrations are version control for your database.
php artisan migrate
php artisan migrate:rollback
Contains database seeder classes for populating your database with test or initial data.
php artisan db:seed

public/

The public directory is the web server’s document root. It contains the entry point (index.php) and publicly accessible assets.
All HTTP requests are routed through public/index.php. Your web server should be configured to serve from this directory.
Contains:
  • index.php - Application entry point
  • Compiled CSS and JavaScript files (generated by Vite)
  • Public assets (images, fonts, etc.)

resources/

The resources directory contains views, raw assets, and language files.
Contains raw CSS files that will be compiled by Vite.Default file:
  • app.css - Main application stylesheet
Contains JavaScript files that will be compiled by Vite.Default files:
  • app.js - Main JavaScript entry point
  • bootstrap.js - Bootstrap configuration (Axios, Echo, etc.)
Contains Blade template files for your application’s views.Default file:
  • welcome.blade.php - Default welcome page
Contains language files for internationalization (created when needed).

routes/

The routes directory contains all route definitions for your application.
Defines routes for your web interface. These routes receive session state, CSRF protection, and cookie encryption.
Route::get('/', function () {
    return view('welcome');
});
Defines console-based command routes using Artisan.
Artisan::command('inspire', function () {
    $this->comment(Inspiring::quote());
});
Defines API routes (created when needed). These routes are stateless and typically return JSON.
Defines broadcast channels for event broadcasting (created when needed).

storage/

The storage directory contains logs, compiled templates, file uploads, and other generated files.
Contains application-generated files and user uploads.Subdirectories:
  • private/ - Private files not accessible via URL
  • public/ - Public files (symlinked to public/storage)
Contains framework-generated files and caches.Subdirectories:
  • cache/ - Application cache
  • sessions/ - Session files (when using file driver)
  • testing/ - Files generated during testing
  • views/ - Compiled Blade templates
Contains application log files.Default file:
  • laravel.log - Main application log file
The storage and bootstrap/cache directories must be writable by your web server.

tests/

The tests directory contains automated tests for your application.
Contains feature tests that test larger portions of your application, including HTTP requests and responses.
php artisan test --filter=Feature
Contains unit tests that test individual classes and methods in isolation.
php artisan test --filter=Unit

Hidden Directories and Files

.github/

Contains GitHub-specific files like workflow configurations for GitHub Actions. Subdirectories:
  • workflows/ - GitHub Actions workflow definitions

.git/

Contains Git version control system data. This directory is created when you initialize a Git repository.
This directory should never be deployed to production servers.

Configuration Files

Defines coding style conventions for editors and IDEs (indentation, charset, etc.).
Defines Git attributes for path-specific settings.
Specifies which files and directories Git should ignore.
Configuration for StyleCI, an automated PHP code style service.

Quick Reference

DirectoryPurpose
app/Core application code (models, controllers, etc.)
bootstrap/Application bootstrapping and cache
config/Configuration files
database/Migrations, factories, and seeders
public/Web server document root
resources/Views and raw assets
routes/Route definitions
storage/Generated files, logs, and uploads
tests/Automated tests
You can create additional directories within app/ as your application grows. Laravel has no strict requirement on application structure.

Build docs developers (and LLMs) love