Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 67 ยท Getting Started

The Project Structure

A guided tour of a Laravel 13 project: app, bootstrap, config, database, public, resources, routes, storage, tests and the slim bootstrap/app.php file.

A fresh Laravel project contains a few dozen files and about a dozen folders. At first it can look like a lot, but each folder has one clear purpose, and once you know the map you always know where to put new code. Laravel 13 uses a deliberately slim skeleton: older versions shipped many files you rarely touched, and newer versions keep only what you actually need and let you add the rest on demand.

This lesson walks the tree from top to bottom, explains what each part is for, and ends with bootstrap/app.php, the one file that now ties the application together.

The top-level map

Here is a typical new project, shortened. Items marked with a slash are folders.

TEXT
example-app/
โ”œโ”€โ”€ app/            your application code (models, controllers, ...)
โ”œโ”€โ”€ bootstrap/      starts the framework; app.php, providers.php, cache/
โ”œโ”€โ”€ config/         configuration files (one per topic)
โ”œโ”€โ”€ database/       migrations, seeders, factories, the SQLite file
โ”œโ”€โ”€ public/         the only folder the web server exposes
โ”œโ”€โ”€ resources/      views, CSS and JavaScript source files
โ”œโ”€โ”€ routes/         web.php, console.php (and api.php when you add it)
โ”œโ”€โ”€ storage/        logs, caches, compiled views, uploaded files
โ”œโ”€โ”€ tests/          Pest or PHPUnit tests
โ”œโ”€โ”€ vendor/         Composer packages (never edit, never commit)
โ”œโ”€โ”€ .env            environment-specific settings (never commit)
โ”œโ”€โ”€ artisan         the command line entry point
โ”œโ”€โ”€ composer.json   PHP dependencies
โ””โ”€โ”€ package.json    JavaScript dependencies
flowchart LR
    P["public/index.php"] --> B["bootstrap/app.php"]
    B --> R["routes/web.php"]
    R --> A["app/ (controllers, models)"]
    A --> V["resources/views"]
    A --> D["database/ and storage/"]
    B --> C["config/ and .env"]

The entry point loads the bootstrap file, which reads configuration and routes; routes call your code in app/.

app: your code

app/ is where you spend most of your time. In a new project it holds very little:

Folders such as Jobs, Policies, Mail, Notifications, Events and Listeners do not exist at first. Artisan creates them the first time you generate such a class, for example php artisan make:job SendReport. That is the slim skeleton at work: no empty folders to wonder about. Laravel autoloads everything under app/ through Composer, using the App\ namespace. A class in app/Models/Post.php is App\Models\Post.

bootstrap

bootstrap/app.php creates the application and sets it up. This is the file that replaced the old Http/Kernel.php, the exception handler and several provider classes. bootstrap/providers.php lists the service providers to load. The bootstrap/cache folder holds generated cache files and must be writable.

config

Each file in config/ returns a PHP array for one topic: app.php, database.php, cache.php, mail.php, queue.php, session.php and so on. You read a value with config('app.name'). Values that differ between machines (passwords, hosts, keys) are read from .env inside these files, a pattern covered in Configuration and Environments.

database

This folder holds everything about the schema and test data:

  • migrations/: files that create and change tables (Migrations).
  • factories/ and seeders/: generate fake or starter data (Seeders and Factories).
  • database.sqlite: the database file if you chose SQLite.

public

public/ is the document root: the only folder the web server should serve. It contains index.php, the front controller that receives every request, plus things browsers must fetch directly: compiled assets in public/build, images, favicon.ico and robots.txt. Everything outside public/ (your .env, your code, your logs) is unreachable from the web. If you ever see a tutorial telling you to point the server at the project root, it is wrong, because that would expose .env.

resources

Source files that are not PHP logic:

routes

routes/web.php maps browser URLs to code. routes/console.php holds closure-based Artisan commands and scheduled tasks. An api.php file is not there by default; php artisan install:api adds it when you build an API (Building JSON APIs with API Resources). See Routing Basics for the next step.

storage

Laravel writes files here at runtime:

  • storage/logs: the log file laravel.log.
  • storage/framework: compiled views, cache files and sessions when you use file-based drivers.
  • storage/app/private and storage/app/public: files you save with the Storage system. To make the public ones reachable, php artisan storage:link creates a symlink from public/storage (File Uploads and the Storage System).

The web server's user must be able to write here. A common cause of mysterious 500 errors is unwritable storage/.

tests

tests/Feature for tests that exercise several parts together (usually HTTP requests), and tests/Unit for small isolated tests. See Testing with Pest.

bootstrap/app.php, the slim configuration file

The file is short. Here is a typical version in a new project (read-only; this is real Laravel):

PHP
<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware): void {
        //
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        //
    })->create();

It reads as a sentence: configure an application, with these route files, with these middleware changes, with these exception rules. The health: '/up' line registers a health-check URL that deploy tools can call. When you later add an API route file or a middleware alias, you do it in this one place.

Try it: walking a directory tree

To see how the folders relate, here is a plain-PHP stand-in. It prints a fake project as a tree, and then answers "where does this kind of file go?" using the rules from this lesson.

PHP Printing a fake project tree

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Now a small "where does it go?" helper. Real Laravel has no such function: php artisan make:... places the file for you. The point is that the placement rule is a convention you can state in one line per file type.

PHP Where does this file go?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with fgets(STDIN)), it gets the next line from this box.

Things you should never do

  • Never commit .env or vendor/ to Git. Both are already in .gitignore.
  • Never point your web server at the project root. Always at public/.
  • Do not edit files under vendor/. Your changes disappear at the next update.
  • Do not put business code into config/, public/ or bootstrap/. Use app/.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which folder should the web server expose as the document root?

    Only public/ should be reachable from the web. Everything else, including .env, stays outside it.
  2. 2. Where does Laravel 13 configure routing files, middleware and exception handling?

    The slim skeleton centralizes these settings in bootstrap/app.php with withRouting(), withMiddleware() and withExceptions().
  3. 3. Why don't new projects contain folders like app/Jobs or app/Policies?

    The slim skeleton only includes what you use. For example php artisan make:job creates app/Jobs the first time.
  4. 4. What is storage/ for?

    storage/ is the writable area for runtime files. It must be writable by the web server user.

Summary

  • app/ holds your code, autoloaded under the App\ namespace.
  • bootstrap/app.php configures routing, middleware and exceptions in one place.
  • config/ returns arrays; database/ holds migrations, factories and seeders.
  • public/ is the only web-exposed folder, and index.php is the front controller.
  • resources/ holds views and assets, routes/ maps URLs, storage/ is writable runtime space and tests/ holds your tests.
  • Never commit .env or vendor/, and never serve the project root.

Next: The Request Lifecycle