app, bootstrap and config
Open a fresh Laravel project and you see about a dozen folders. Three of them decide how the app is built and how it behaves: app/ for your classes, bootstrap/ for starting the app, and config/ for settings. Put things in the right one and Laravel finds them without being told.
The rule
app/ is your code, bootstrap/ starts it, config/ tunes it.
app/: your own PHP classes. Everything here uses the App\ namespace, so app/Models/Book.php is App\Models\Book.
app/Models/: Eloquent models, such asUserandBookapp/Http/Controllers/: controllersapp/Providers/: service providers, such asAppServiceProvider
More folders, such as app/Jobs or app/Policies, appear when you generate those classes with Artisan.
bootstrap/: building the app.
bootstrap/app.php: routing, middleware and exception setupbootstrap/providers.php: the list of service providers to loadbootstrap/cache/: files Laravel generates to start faster. Never edit them.
config/: settings, one file per area, such as app.php, database.php, mail.php and session.php. Each file returns an array, and values that change per machine are pulled from .env:
// config/lendly.php
return [
'loan_days' => env('LOAN_DAYS', 14),
];Code reads settings with dot notation, file name first:
$days = config('lendly.loan_days'); // 14 unless .env says otherwiseSome config files are hidden in a new app to keep it small. php artisan config:publish copies them in when you need to change one.
The shortcut
Call env() only inside config/. Everywhere else, use config(). In production you run php artisan config:cache, which saves all settings into one file, and after that env() calls outside config files return null.
Name the value
LOAN_DAYS=21goes in.env, because it may differ per environment.
Drills
Answer fast — trust the rule.
Where does the Book model normally live?
How should a controller read the mail sender's address?
Which file lists the service providers Laravel loads?
After php artisan config:cache, what does env('LOAN_DAYS') return inside a controller?
Remember
app/is your code,bootstrap/starts it,config/tunes it.env()only inside config files;config('file.key')everywhere else.- Trap: never edit
bootstrap/cache, since Laravel rebuilds it.
