Folder Structure in Laravel 12

Important Folders and Files in Laravel 12 Project explained in details with real time examples
📂 app/ — The Brain of Your App
This is where the core logic of your Laravel project lives.
Http/ — Contains your Controllers and Middleware.
Controllers are like traffic police. When a user visits your site, controllers decide what to do.
Middleware are like security guards. They check things before letting users through (like “is this user logged in?”).
Models/ — These represent your database tables. For example, User.php is your code’s connection to the users table.
🧠 Real-Life Analogy: Think of a food delivery app:
When someone places an order — that logic goes in a controller.
The order details that get saved in a table — that comes from a model.
⚙️ bootstrap/ — Laravel’s Start-Up Booster
This folder contains files that help Laravel boot up (start).
app.php — This file starts up your Laravel application.
You won’t usually touch this folder. Just know Laravel reads from here when starting.
🧠 Real-Life: Think of this like the ignition key of your car. It starts the engine but you don’t touch it every day.
🛠 config/ — App Settings & Options
This is where Laravel stores its configuration settings — like app name, timezone, database connection, etc.
app.php — Set app name, timezone, locale
database.php — Configure your database
mail.php — Email sending setup
🧠 Real-Life: Like settings in your phone — ringtone, brightness, Wi-Fi, etc. This is your Laravel settings menu.
🏗 database/ — Where Tables Are Designed
This folder contains files related to database structure and data:
migrations/ — Define what your database tables should look like
seeders/ — Fill tables with sample data
factories/ — Automatically create fake data for testing
🧠 Example: Want to make a products table with name, price, stock? Create a migration in this folder.
🧠 Real-Life: Think of this as your restaurant’s kitchen menu. You decide what dishes (tables) exist and what ingredients (columns) they need.
🌐 public/ — The Only Folder Users See
This is the front door of your Laravel app. Anything the user sees on the browser comes from here.
index.php — The main entry point of your app
You can place CSS, JS, and image files here
🧠 Real-Life: This is like the entrance to a shopping mall. Customers only see this, not what’s behind the scenes.
🎨 resources/ — Your Views, Your Design
This is where the frontend of your website lives — the stuff users actually see like HTML pages.
views/ — Contains all your Laravel Blade files (.blade.php) — your web pages
lang/ — Text translations if you make a multilingual site
css/, js/ — Optional: You can put your custom CSS and JS here
🧠 Example: Want a Contact Us page? Create contact.blade.php inside resources/views.
🧠 Real-Life: These are your restaurant’s tables, lights, paint, and decoration. The customer experience!
🗺 routes/ — The Map of Your Website
This is where Laravel keeps a list of all available URLs (routes).
web.php — For frontend/browser-based routes
api.php — For app or mobile API routes
🧠 Example:
Route::get(‘/about’, function () {
return view(‘about’);
});
When someone visits your-site.com/about, they’ll see the about.blade.php page.
🧠 Real-Life: Just like a receptionist telling visitors where to go in a building.
📦 storage/ — Laravel’s Locker Room
Laravel saves all temporary stuff here:
Uploaded files
Cache files
Logs (errors, activity)
🧠 Real-Life: Like a warehouse or locker room where things are stored privately — no public access.
🔍 tests/ — For Automated Testing
This is where you can write test scripts to automatically check if everything in your app works.
🧠 Beginner Note: You can ignore this for now, but it’s great for large apps where bugs must be caught early.
🧠 Real-Life: Like a robot checking every room in a hotel to make sure lights and water are working.
📄 .env — The Secret Settings File
This file stores sensitive settings like:
Your database username/password
Your mail SMTP credentials
App name, base URL, etc.
🧠 Important: Never share this file publicly — it has your secrets!
🧠 Real-Life: Like the diary where you keep your Wi-Fi password, email password, etc.
🧙 artisan — Laravel’s Magic Wand (Command Tool)
This is a file you use in the terminal. You type commands like:
php artisan make:controller HomeController
php artisan migrate
php artisan serve
Laravel will do these jobs instantly.
🧠 Real-Life: Like telling your assistant, “Please create a new folder for me.” and it just happens.
📃 composer.json — The Recipe List
This file keeps track of every package/tool your Laravel app depends on.
🧠 Real-Life: Like a kitchen recipe card — it lists every ingredient (library) used in the app.
When you install a new package, it gets added here.