Skip to content

Sobhan-nz/laravel-folder-structure-tutorial-

Repository files navigation

📂 Laravel Directory Structure

In this post, we’ll explore Laravel’s default folder and file structure.
This structure is designed to keep your application’s logic, configuration, and resources well organized.


1. app/

  • The core of your application.
  • Contains main application logic such as Models, Controllers, Middleware, etc.
  • Important subfolders:
    • Http/ → Controllers, Middleware, and Requests.
    • Models/ → Eloquent models for database interaction.
    • Console/ → Custom Artisan commands.
    • Providers/ → Service providers.

2. bootstrap/

  • Contains the files needed to bootstrap Laravel.
  • app.php initializes the application.
  • The cache/ folder stores cached routes and configuration files.

3. config/

  • Holds all configuration files for the project.
  • Examples: app.php, database.php, mail.php, etc.
  • Values from .env are loaded here.

4. database/

  • Database-related files:
    • migrations/ → Create or modify database tables.
    • factories/ → Generate test data.
    • seeders/ → Insert initial data.

5. public/

  • The only directory accessible from the web.
  • Contains:
    • index.php → The entry point of the application.
    • Static files (CSS, JS, images).

6. resources/

  • Contains raw resources for the application:
    • views/ → Blade templates.
    • lang/ → Language files.
    • css/, js/ → Front-end source files.

7. routes/

  • Route definitions:
    • web.php → Web routes (with sessions & cookies).
    • api.php → API routes (stateless).
    • console.php → Artisan command routes.
    • channels.php → Broadcast channels.

8. storage/

  • Stores files generated by the application:
    • app/ → Uploaded files.
    • framework/ → Cache, sessions, and compiled templates.
    • logs/ → Application logs.

9. tests/

  • Unit and Feature test files.

10. Other important files:

  • vendor/ → Composer dependencies.
  • .env → Environment configuration.
  • artisan → Laravel CLI tool.
  • composer.json → Composer package list.
  • package.json → JavaScript dependencies.

📌 Conclusion

Laravel’s organized directory structure helps developers manage their applications efficiently.
Familiarity with this structure will improve your development workflow and code maintenance.

About

In this post, we’ll explore Laravel’s default folder and file structure.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages