Laravel Application Folder Structure Overview
This article provides a comprehensive overview of Laravel's default application folder structure, explaining the purpose of each top‑level directory such as app, bootstrap, config, database, public, resources, routes, storage, tests, and vendor, and detailing the sub‑folders within the app directory like Console, Http, and Providers.
Folder Structure
Introduction
The default Laravel application layout offers a solid starting point for projects of any size, but developers are free to reorganise it. Laravel imposes almost no restrictions on class locations as long as Composer can autoload them.
Why there is no dedicated models directory?
New Laravel users often wonder about the missing models folder. The omission is intentional because the term "model" can refer either to the entire business‑logic layer or specifically to classes that interact with a relational database. Consequently, Eloquent models are placed under the app directory by default, though you may store them elsewhere.
Root Directory
app Directory
The app folder holds the core code of the application; most of your classes belong here. It contains several sub‑directories such as Broadcasting, Console, Events, Exceptions, Http, Jobs, Listeners, Mail, Notifications, Policies, Providers, and Rules. These sub‑folders are created automatically when you generate the corresponding classes via Artisan commands.
bootstrap Directory
The bootstrap folder contains the framework bootstrap file app.php and a cache directory where Laravel stores compiled files such as route and service caches to improve performance.
config Directory
The config folder stores all configuration files for the application. Reviewing these files helps you understand the available options.
database Directory
The database folder holds migration files, seeders, model factories, and can also serve as a place for an SQLite database.
public Directory
The public folder contains the entry point index.php for all HTTP requests and hosts public assets such as images, JavaScript, and CSS.
resources Directory
The resources folder includes view templates, uncompiled assets (LESS, SASS, JavaScript) and language files.
routes Directory
The routes folder defines all route files. By default Laravel provides web.php, api.php, console.php, and channels.php. web.php routes use the web middleware group (session, CSRF, cookie encryption). api.php routes use the api middleware group (rate limiting, stateless authentication).
storage Directory
The storage folder stores compiled Blade templates, session files, caches and other framework‑generated files. It is divided into app, framework, and logs. The storage/app/public sub‑directory can hold user‑generated files; a symbolic link created with php artisan storage:link makes them publicly accessible.
tests Directory
The tests folder contains automated test classes. Each test class should end with Test. Run tests with phpunit or php vendor/bin/phpunit.
vendor Directory
The vendor folder holds all Composer‑installed dependencies.
App Directory Details
Most of your application code resides in the app directory, which is namespaced as App and follows PSR‑4 autoloading. Sub‑folders such as Console, Http, and Providers serve as the API for the core of the application. The Console folder stores Artisan commands, while Http contains controllers, middleware, and form requests.
When you generate classes with Artisan (e.g., make:job), the corresponding directories (e.g., app/Jobs) are created automatically.
Tip: Many classes are generated in the app directory via Artisan. To see available make commands, run php artisan list make .
Broadcasting Directory
The Broadcasting folder holds channel classes generated with make:channel. It is created when you first generate a channel.
Console Directory
The Console folder contains custom Artisan commands generated with make:command and the console kernel where you register them and define scheduled tasks.
Events Directory
The Events folder (created via event:generate or make:event) stores event classes used to decouple parts of the application.
Exceptions Directory
The Exceptions folder holds the global exception handler ( Handler) where you can customise exception logging and rendering.
Http Directory
The Http folder contains controllers, middleware, and request classes that process incoming HTTP requests.
Jobs Directory
The Jobs folder (created with make:job) stores queueable job classes, which may run synchronously or be dispatched to a queue.
Listeners Directory
The Listeners folder (created via event:generate or make:listener) holds listener classes that react to events, such as sending a welcome email after a UserRegistered event.
Mail Directory
The Mail folder (generated with make:mail) contains mailable classes that encapsulate email logic and use Mail::send to dispatch messages.
Notifications Directory
The Notifications folder (generated with make:notification) stores notification classes that can be sent via various channels like email, Slack, SMS, or database.
Policies Directory
The Policies folder (generated with make:policy) contains authorization policy classes that determine whether a user may perform a given action on a resource.
Providers Directory
The Providers folder holds service provider classes that bootstrap the application, register services, and listen for events.
Rules Directory
The Rules folder (generated with make:rule) contains custom validation rule objects that encapsulate complex validation logic.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
