/Dev/HowTo
Last modified: May 29 2025 19:06:58
Laravel structure
Laravel's basic structure follows a clean MVC (Model-View-Controller) pattern, organized in a way that separates logic, presentation, and data. Here's an overview of the default Laravel project structure:
your-project/
├── app/ # Application core code
│ ├── Console/ # Artisan commands
│ ├── Exceptions/ # Error handling
│ ├── Http/ # Controllers, middleware, requests
│ │ ├── Controllers/ # Route handlers (MVC Controllers)
│ │ ├── Middleware/ # HTTP middleware
│ │ └── Requests/ # Form request validation
│ ├── Models/ # Eloquent models (data layer)
│ └── Providers/ # Service providers (bootstrapping)
│
├── bootstrap/ # Framework bootstrap/start files
│ └── app.php # Entry point for bootstrapping the app
│
├── config/ # Configuration files (app, database, etc.)
├── database/ # Migrations, factories, seeders
│ ├── factories/
│ ├── migrations/
│ └── seeders/
│
├── public/ # Publicly accessible files (index.php, assets)
│ └── index.php # Front controller (entry point for web requests)
│
├── resources/ # Views, raw assets (Sass, JS), translations
│ ├── views/ # Blade templates (HTML views)
│ └── lang/ # Language files
│
├── routes/ # Route definitions
│ ├── web.php # Routes for the web (uses session & CSRF)
│ ├── api.php # Routes for API (stateless)
│ └── console.php # Artisan commands
│
├── storage/ # Logs, compiled views, cache, user uploads
├── tests/ # Unit and feature tests
├── vendor/ # Composer dependencies
├── artisan # CLI for Laravel (Artisan tool)
├── .env # Environment configuration
├── composer.json # PHP dependencies
└── package.json # JS dependencies (optional frontend build tools)
Key Concepts:
MVC : Models (app/Models), Views (resources/views), Controllers (app/Http/Controllers)
Routes : Defined in routes/web.php or routes/api.php
Artisan : Laravel’s CLI, invoked with php artisan
Eloquent : Laravel’s ORM, models go in app/Models
Blade : Laravel’s templating engine, lives in resources/views
Minimal Flow Example:
User visits /users → Route defined in routes/web.php
Route points to UserController@index
UserController queries data using a User model
Controller returns a Blade view with data
View is rendered and served via public/index.php
In a Laravel project, the framework is structured in a way that separates core framework code from your application code , so when you update Laravel (e.g., via Composer), only the framework is updated — your application code remains untouched as long as you haven't edited the framework files directly .
✅ Parts That Are Updated During a Laravel Framework Update
When you run:
composer update
Laravel updates packages defined in composer.json , especially:
🛠 Framework Core (stored in vendor/laravel/)
vendor/laravel/framework/: Laravel's internal code (routing, requests, responses, validation, etc.)
vendor/*: Other dependencies like Symfony components, Guzzle, etc.
bootstrap/cache/*: May be regenerated (e.g., config.php, routes.php)
🧱 Your Application Code (Untouched by Laravel Updates)
Laravel does NOT touch your code in:
/Dev/HowTo (Last modified: May 29 2025 19:06:58 )Laravel structure
Laravel's basic structure follows a clean MVC (Model-View-Controller) pattern, organized in a way that separates logic, presentation, and data. Here's an overview of the default Laravel project structure:
your-project/
├── app/ # Application core code
│ ├── Console/ # Artisan commands
│ ├── Exceptions/ # Error handling
│ ├── Http/ # Controllers, middleware, requests
│ │ ├── Controllers/ # Route handlers (MVC Controllers)
│ │ ├── Middleware/ # HTTP middleware
│ │ └── Requests/ # Form request validation
│ ├── Models/ # Eloquent models (data layer)
│ └── Providers/ # Service providers (bootstrapping)
│
├── bootstrap/ # Framework bootstrap/start files
│ └── app.php # Entry point for bootstrapping the app
│
├── config/ # Configuration files (app, database, etc.)
├── database/ # Migrations, factories, seeders
│ ├── factories/
│ ├── migrations/
│ └── seeders/
│
├── public/ # Publicly accessible files (index.php, assets)
│ └── index.php # Front controller (entry point for web requests)
│
├── resources/ # Views, raw assets (Sass, JS), translations
│ ├── views/ # Blade templates (HTML views)
│ └── lang/ # Language files
│
├── routes/ # Route definitions
│ ├── web.php # Routes for the web (uses session & CSRF)
│ ├── api.php # Routes for API (stateless)
│ └── console.php # Artisan commands
│
├── storage/ # Logs, compiled views, cache, user uploads
├── tests/ # Unit and feature tests
├── vendor/ # Composer dependencies
├── artisan # CLI for Laravel (Artisan tool)
├── .env # Environment configuration
├── composer.json # PHP dependencies
└── package.json # JS dependencies (optional frontend build tools)
Key Concepts:
MVC : Models (app/Models), Views (resources/views), Controllers (app/Http/Controllers)
Routes : Defined in routes/web.php or routes/api.php
Artisan : Laravel’s CLI, invoked with php artisan
Eloquent : Laravel’s ORM, models go in app/Models
Blade : Laravel’s templating engine, lives in resources/views
Minimal Flow Example:
User visits /users → Route defined in routes/web.php
Route points to UserController@index
UserController queries data using a User model
Controller returns a Blade view with data
View is rendered and served via public/index.php
In a Laravel project, the framework is structured in a way that separates core framework code from your application code , so when you update Laravel (e.g., via Composer), only the framework is updated — your application code remains untouched as long as you haven't edited the framework files directly .
✅ Parts That Are Updated During a Laravel Framework Update
When you run:
composer update
Laravel updates packages defined in composer.json , especially:
🛠 Framework Core (stored in vendor/laravel/)
vendor/laravel/framework/: Laravel's internal code (routing, requests, responses, validation, etc.)
vendor/*: Other dependencies like Symfony components, Guzzle, etc.
bootstrap/cache/*: May be regenerated (e.g., config.php, routes.php)
🧱 Your Application Code (Untouched by Laravel Updates)
Laravel does NOT touch your code in:
app/: Your controllers, models, services, etc.
routes/: Your route definitions
resources/views/: Blade templates
config/: Your config files
database/: Your migrations and seeders
.env: Your environment settings
public/: Your static files and entrypoint (index.php)
composer.json / package.json: Unless you manually modify them
🧠 Important Note on Updates
Laravel itself is modular, and each release (especially major versions ) might introduce breaking changes . Even though your app files are untouched, the behavior might change:
Method signatures updated
Deprecated features removed
Config file structure changed (new keys added in fresh installs)
🔐 Safe Update Practice
Check the upgrade guide on laravel.com/docs/releases
Compare your config files with new defaults using:
php artisan config:clear
php artisan config:cache
Test locally or on staging before updating production
Use Git to track any manual changes you've made to framework files (though modifying core files is discouraged)