database, storage, tests and vendor
Four folders remain, and each answers a different question. Where is the shape of my data? Where does the app write files? Where do I prove it works? Where is everyone else's code? Mix them up and you end up committing gigabytes of packages or losing a member's uploaded photo.
The rule
database/ shapes data, storage/ collects output, tests/ proves it, vendor/ borrows.
database/
migrations/: PHP files that create and change tables, run withphp artisan migrate.factories/: recipes for fake rows, used in tests and seeding.seeders/: code that fills tables with starting data, run withphp artisan db:seed.database.sqlite: the database file itself, when you use SQLite.
storage/: what the running app writes.
storage/app/: files your code saves.storage/app/publicis for files the public should see, such as avatars.storage/framework/: compiled views, cache files and sessions.storage/logs/laravel.log: the log, and the first place to look when a page errors.
Uploaded files in storage/app/public are not reachable until you run:
php artisan storage:linkThat creates a public/storage link, so storage/app/public/avatars/ana.jpg is served at /storage/avatars/ana.jpg.
tests/
tests/Feature/: tests that send requests through the app, such as "GET /books returns 200".tests/Unit/: tests of one small class on its own.
Run them with php artisan test.
vendor/: every Composer package, including Laravel itself in vendor/laravel/framework. It is listed in .gitignore, and composer install rebuilds it from composer.lock.
The shortcut
Ask "who writes this file?" You write it by hand → it is committed (database/, tests/). The running app writes it → storage/, not committed. Composer writes it → vendor/, not committed.
create_loans_table migration
Written by you, so it lives in
database/migrationsand is committed.
The trap is fixing a bug by editing a file in vendor/. The next composer install wipes your change silently.
Drills
Answer fast — trust the rule.
Where do you look first when a page shows a server error?
Which folder defines the structure of the books table?
Avatars saved in storage/app/public show a 404 in the browser. What is missing?
A teammate clones Lendly and has no vendor/ folder. What should they run?
A test sends GET /books and checks for status 200. Where does it belong?
Remember
database/shapes data,storage/collects output,tests/proves it,vendor/borrows.- Who writes it? You → commit it. The app or Composer → don't.
- Trap: never edit
vendor/.composer installoverwrites it.
