dataDesk BLOG

Welcome to the blog of Mr.G

Nature

/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:

  1. User visits /users → Route defined in routes/web.php
  2. Route points to UserController@index
  3. UserController queries data using a User model
  4. Controller returns a Blade view with data
  5. 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

  1. Check the upgrade guide on laravel.com/docs/releases
  2. Compare your config files with new defaults using:

    php artisan config:clear
    php artisan config:cache
  3. Test locally or on staging before updating production
  4. Use Git to track any manual changes you've made to framework files (though modifying core files is discouraged)


Who I am

"Just me, myself, and I, exploring the universe of unknownment, embracing the mystery of what lies beyond, one star at a time."

Share this page on Facebook | X.com | Reddit

Latest Posts

  • Image Lem - Warren Buffett walked into a University of Florida classroom in 1998 ... [2098423133938356224] (1)
    Published: September 12 2026
    Read
  • Image Sam Stoffel - Jack Dorsey's simple rule for success in business [2089319019065057280]
    Published: August 19 2026
    Read
  • Image Peter-Steinberger-What-Happens-When-4.7-_1786407922546
    Published: August 16 2026
    Read
  • Image Monitor_server_action____
    Published: August 16 2026
    Read
  • Image Disk_and_RAID_testing_commands
    Published: July 31 2026
    Read

Tags

WebDev New York London AI NORWAY DIY Ideas Life Family News Clothing Invest Sports Health