Basics

Understanding the Folder Structure of a Laravel Project

6 min read · By the GudangCode Team

Opening a Laravel project for the first time can feel like entering a large building without a map. Yet the structure is consistent across every project. Once you memorise what each main folder does, changing and customising source code becomes far more directed.

app/ — The Application's Brain

This is where the core logic lives. The sub-folders you touch most:

  • app/Models/ — classes that represent database tables (e.g. User, Product).
  • app/Http/Controllers/ — controllers that receive requests and return views or data.
  • app/Http/Middleware/ — request filters, for example a login check.

routes/ — The Address Map

The file routes/web.php defines the URLs visitors can open and which controller handles each. When you want to know "where does this page come from", start here. APIs live separately in routes/api.php.

resources/views/ — The Presentation (Blade)

All .blade.php files live here. Blade is Laravel's template engine that mixes HTML with a little special syntax such as @foreach and {{ $variable }}. To change text or a page layout, this folder is your destination.

config/ — Detailed Settings

Contains configuration files such as config/app.php and config/database.php. Their values often read from .env. You rarely need to edit this folder directly, but it is good to know it is there.

database/ — Schema and Starter Data

  • database/migrations/ — table blueprints; run with php artisan migrate.
  • database/seeders/ — fill starter data such as an admin account.
  • database/factories/ — generate fake data for testing.

public/ — The Public Entry Point

Only this folder should be reachable directly from the internet. The file public/index.php is the entry point for every request. Built assets (CSS/JS) and public images also go here. On hosting, the document root must point to the public folder.

storage/ and bootstrap/cache/ — Writable Areas

Laravel writes logs, cache, and uploaded files to storage/. These two folders must be writable by the server; most 500 errors during deployment come from their permissions.

Important Files at the Root

  • .env — secret per-environment configuration.
  • composer.json — list of PHP dependencies.
  • artisan — Laravel's command-line tool.

With this map, instead of guessing you can head straight to the right folder: change the look in resources/views, change the flow in Controllers, and change the data structure in migrations.


Tim Support
Online
Isi data dulu untuk mulai chat:
Beri rating & testimoni sebelum menutup:
Live chat by gudangcode.com