Introduction
Laravel’s default application structure provides a solid starting point for both large and small applications. However, you’re free to organize your application any way you like. Laravel imposes almost no restrictions on where any given class is located—as long as Composer can autoload it, you’re good.The root directory
When you create a new Laravel project, the following directory structure is generated:The app/ directory
This directory holds the core code of your application.
Almost every class in your application—controllers, models, middleware—lives here.
By default, it contains the Http, Models, and Providers subdirectories.
When you generate classes via Artisan commands, other subdirectories are created automatically.
The bootstrap/ directory
Contains the app.php file that boots the framework.
It also includes a cache/ directory that stores performance-optimization files such as the route and services caches.
The config/ directory
Contains all of your application’s configuration files.
It’s a great idea to read through these files and familiarize yourself with all of the options available to you.
The database/ directory
Contains database migrations, model factories, and seeders.
You can also place your SQLite database file here.
The public/ directory
Contains the index.php file, which is the entry point for all requests to your application.
It also holds assets such as images, JavaScript, and CSS.
The resources/ directory
Contains your views, as well as raw, un-compiled assets such as CSS or JavaScript.
The routes/ directory
Contains all of your application’s route definitions.
By default, two route files are included: web.php and console.php.
The storage/ directory
Contains framework-generated files such as logs, compiled Blade templates, file-based sessions, and file caches.
It is divided into three subdirectories: app/, framework/, and logs/.
The tests/ directory
Contains your automated tests.
Sample unit and feature tests using Pest or PHPUnit are included out of the box.
The vendor/ directory
Contains your Composer dependencies. This directory should not be committed to source control.
The app/ directory in detail
Many of the classes in the app directory can be generated via Artisan commands.
To review the available commands, run:
Http/ directory
Http/ directory
Contains controllers, middleware, and form requests.
Nearly all of the logic for handling requests entering your application lives here.
Models/ directory
Models/ directory
Contains all Eloquent model classes.
A “model” corresponds to each database table and is used to query and insert data.
Providers/ directory
Providers/ directory
Contains all of your application’s service providers.
Service providers bind services into the container, register events, and perform the tasks needed to boot your application.
Console/ directory
Console/ directory
Contains all of your custom Artisan commands.
You can generate them with the
make:command command.Exceptions/ directory
Exceptions/ directory
Contains all of your application’s custom exceptions.
You can generate them with the
make:exception command.Important files
The .env file
Manages configuration values that differ per environment (database credentials, API keys, and so on).
The env() helper is used from configuration files in config/ to reference them.
The artisan file
The entry point for the Artisan command-line interface.
Run commands with php artisan <command name>.
Next steps
Routing
Learn how to define routes and connect URLs to your application logic.