Root Directory
The root directory contains several important files and directories that form the foundation of your Laravel application.Root Files
artisan
artisan
The Artisan command-line interface file. This is the entry point for running all Artisan commands.
composer.json
composer.json
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.
package.json
package.json
Defines your application’s JavaScript dependencies and build scripts. Used by npm or yarn for frontend asset management.
phpunit.xml
phpunit.xml
Configuration file for PHPUnit testing framework. Defines test suites, environment variables, and coverage settings.
vite.config.js
vite.config.js
Configuration file for Vite, the modern frontend build tool used by Laravel for compiling and bundling assets.
.env.example
.env.example
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/
Theapp directory contains the core code of your application. This is where most of your application’s classes will reside.
app/Http/
app/Http/
Contains controllers, middleware, and form requests. This directory handles the HTTP layer of your application.Subdirectories:
Controllers/- Controller classes that handle incoming HTTP requestsMiddleware/- HTTP middleware for filtering requestsRequests/- Form request validation classes
app/Models/
app/Models/
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
app/Providers/
app/Providers/
Service provider classes that bootstrap various components of your application.Default Providers:
AppServiceProvider.php- General application service provider
app/Console/
app/Console/
Contains custom Artisan commands (created when you generate commands).
app/Exceptions/
app/Exceptions/
Contains exception handling classes for your application (created when needed).
bootstrap/
Thebootstrap directory contains the application bootstrapping files.
bootstrap/cache/
bootstrap/cache/
Contains framework generated files for performance optimization, including compiled services and package manifests.
This directory must be writable by your web server.
config/
Theconfig directory contains all of your application’s configuration files.
Configuration Files
Configuration Files
app.php- Core application configuration (name, environment, timezone)auth.php- Authentication guards and providers configurationcache.php- Cache store configuration (Redis, Memcached, file, etc.)database.php- Database connection configurationfilesystems.php- File storage configuration (local, S3, etc.)logging.php- Logging channels and handlers configurationmail.php- Email service configurationqueue.php- Queue connection configurationservices.php- Third-party service credentialssession.php- Session storage and behavior configuration
Configuration values can reference environment variables using the
env() helper function.database/
Thedatabase directory contains database-related files.
database/factories/
database/factories/
Contains model factory classes for generating fake data during testing and seeding.
database/migrations/
database/migrations/
Contains database migration files that define your database schema. Migrations are version control for your database.
database/seeders/
database/seeders/
Contains database seeder classes for populating your database with test or initial data.
public/
Thepublic 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.index.php- Application entry point- Compiled CSS and JavaScript files (generated by Vite)
- Public assets (images, fonts, etc.)
resources/
Theresources directory contains views, raw assets, and language files.
resources/css/
resources/css/
Contains raw CSS files that will be compiled by Vite.Default file:
app.css- Main application stylesheet
resources/js/
resources/js/
Contains JavaScript files that will be compiled by Vite.Default files:
app.js- Main JavaScript entry pointbootstrap.js- Bootstrap configuration (Axios, Echo, etc.)
resources/views/
resources/views/
Contains Blade template files for your application’s views.Default file:
welcome.blade.php- Default welcome page
resources/lang/
resources/lang/
Contains language files for internationalization (created when needed).
routes/
Theroutes directory contains all route definitions for your application.
routes/web.php
routes/web.php
Defines routes for your web interface. These routes receive session state, CSRF protection, and cookie encryption.
routes/console.php
routes/console.php
Defines console-based command routes using Artisan.
routes/api.php
routes/api.php
Defines API routes (created when needed). These routes are stateless and typically return JSON.
routes/channels.php
routes/channels.php
Defines broadcast channels for event broadcasting (created when needed).
storage/
Thestorage directory contains logs, compiled templates, file uploads, and other generated files.
storage/app/
storage/app/
Contains application-generated files and user uploads.Subdirectories:
private/- Private files not accessible via URLpublic/- Public files (symlinked topublic/storage)
storage/framework/
storage/framework/
Contains framework-generated files and caches.Subdirectories:
cache/- Application cachesessions/- Session files (when using file driver)testing/- Files generated during testingviews/- Compiled Blade templates
storage/logs/
storage/logs/
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/
Thetests directory contains automated tests for your application.
tests/Feature/
tests/Feature/
Contains feature tests that test larger portions of your application, including HTTP requests and responses.
tests/Unit/
tests/Unit/
Contains unit tests that test individual classes and methods in isolation.
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
.editorconfig
.editorconfig
Defines coding style conventions for editors and IDEs (indentation, charset, etc.).
.gitattributes
.gitattributes
Defines Git attributes for path-specific settings.
.gitignore
.gitignore
Specifies which files and directories Git should ignore.
.styleci.yml
.styleci.yml
Configuration for StyleCI, an automated PHP code style service.
Quick Reference
| Directory | Purpose |
|---|---|
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.