Laravel Directory structure for beginners
✅ Laravel Folder Structure

๐ app/
This folder contains the main code of your application.
Http/ – Your controllers and middleware live here (handles user requests).
Models/ – These are used to talk to the database (like User.php).
Providers/ – These files help start services like routes, events, etc.
๐ bootstrap/
Used to boot (start) your Laravel app.
- It also contains a cache folder to store compiled files for faster loading.
๐ config/
All the settings of your app are here.
Examples:
app name
timezone
mail configuration
database info, etc.
๐ database/
Contains everything related to your database.
migrations/ – Code for creating or changing tables.
seeders/ – Used to add sample data.
factories/ – Generate fake data for testing.
๐ public/
This is the only folder visible to the user in the browser.
index.php is the file that starts Laravel.
You can also store images, CSS, and JavaScript here.
๐ resources/
This folder has your HTML views and frontend files.
views/ – Contains Blade templates (Laravel’s HTML files).
css/ and js/ – For custom styles and scripts.
๐ routes/
This is where you define URLs for your app.
web.php – For browser routes (like homepage, about page).
console.php – For Artisan CLI commands.
Example:
Route::get('/', function () {
return view('welcome');
});
๐ storage/
Used to store files, like:
logs
uploaded files
cache files
Laravel uses this folder for internal data.
๐ tests/
Write tests here to check if your app works properly.
๐ vendor/
Contains all the Laravel files and libraries installed via Composer.
๐ Don't touch this folder manually.
๐ง Important Files
.env – Important settings like database, mail, app key, etc.
artisan – Command line tool to run Laravel commands.
composer.json – Keeps track of all PHP libraries.
vite.config.js – Settings for CSS/JS build tools.
package.json – Used for JavaScript packages (NPM).
✅ Summary Table
| Folder/File | What it Does |
app/ | Main app logic (controllers, models) |
bootstrap/ | Starts Laravel app |
config/ | App settings |
database/ | Migrations and sample data |
public/ | Browser-visible files |
resources/ | Views and frontend code |
routes/ | Defines URLs |
storage/ | Stores logs, files, cache |
tests/ | App testing code |
vendor/ | Laravel framework and packages |
.env | Environment settings |
artisan | Laravel command line tool |
Explanation in Hinglish
✅ Main Laravel Project Structure
your-project/
│
├── app/
├── bootstrap/
├── config/
├── database/
├── public/
├── resources/
├── routes/
├── storage/
├── tests/
├── vendor/
│
├── .env
├── artisan
├── composer.json
├── vite.config.js
└── ...
๐ app/ – Your core application code
Yeh folder Laravel ka core hota hai, jisme controller, models, and logic rehta hai.
Http/ – Controllers, Middleware, and requests yahan hote hain.
Models/ – Aapke database models (e.g., User.php) yahan bante hain.
Providers/ – Laravel ki services register karne ke liye.
๐ bootstrap/
Laravel ko boot (start) karne ke liye yeh folder use hota hai.
app.php – Framework start karne ka file.
cache/ – Laravel ka optimization aur caching data.
๐ config/
Saare configuration files yahan hote hain (like mail, database, app name, etc.)
Example: app.php, database.php, mail.php, etc.
๐ database/
Database se related saari cheezein:
migrations/ – Table create/edit ka code.
seeders/ – Sample data insert karne ke liye.
factories/ – Fake data generate karne ke liye (testing).
๐ public/
Yeh folder web-accessible hota hai. Jab user aapka site kholta hai, yeh folder serve hota hai.
index.php – Laravel ka entry point.
css/, js/ – Static assets like images, JS, CSS.
๐ resources/
Views aur frontend assets ke liye.
views/ – Blade templates (like HTML) yahan likhte hain.
css/ & js/ – Frontend code likhne ke liye.
๐ routes/
Saare URL routes yahan define hote hain.
web.php – Browser ke routes (GET, POST).
console.php – Artisan CLI ke liye.
api.php (not shown here but usually present) – API ke routes ke liye.
๐ง Example route in web.php:
Route::get('/', function () {
return view('welcome');
});
๐ storage/
Logs, user uploads, and framework data ke liye.
logs/ – Errors and logs.
app/ – Uploaded files.
framework/ – Cache, sessions, views storage.
๐ tests/
Application ke test cases likhne ke liye (PHPUnit ya Pest use karke).
๐ vendor/
All packages and Laravel framework files jo Composer install karta hai.
❌ Never touch this manually.
๐ง Important Root Files:
.env– Project ke environment/config (DB, mail, etc.)artisan– Laravel CLI tool. Use it to run commands:php artisan serve php artisan migratecomposer.json– Installed PHP packages ka record.vite.config.js– Frontend build configuration (Vite for assets).package.json– NPM packages list (for JS & CSS).
๐ Summary in Hinglish
| Folder/File | Kaam (Use) |
app/ | Controllers, Models, Logic |
bootstrap/ | Laravel ko start karne ka system |
config/ | App ke settings/configs |
database/ | Tables banane ka code + test data |
public/ | Browser se visible files (index.php) |
resources/ | Views (HTML) + frontend code |
routes/ | URLs define karne ke liye |
storage/ | Logs, uploads, cache |
tests/ | App testing |
vendor/ | All Laravel + 3rd party libraries |
✅ Main Folders You Should Work On First
1. ๐ routes/web.php
๐น Why?
This is where you define your website's URLs and actions.
๐ธ Example:
phpCopyEditRoute::get('/', function () {
return view('welcome');
});
➡️ Start here to create routes like /about, /contact, etc.
2. ๐ resources/views/
๐น Why?
This folder contains your Blade templates – basically the HTML pages of your app.
๐ธ Example:
Create a file like about.blade.php to design your "About Us" page.
3. ๐ app/Http/Controllers/
๐น Why?
This is where you write your logic for routes using Controllers.
๐ธ Example:
If you want to handle form submissions, database access, etc.
➡️ Use php artisan make:controller PageController to create a controller.
4. ๐ app/Models/
๐น Why?
If you're using a database, Models help you interact with tables.
๐ธ Example:
phpCopyEdit$user = User::all(); // Gets all users
➡️ Use php artisan make:model Post to create a model.
5. ๐ resources/css/ and resources/js/ (optional at first)
๐น If you’re adding custom styles or JS, you can update these.
Comments
Post a Comment