Ad Code

Responsive Advertisement

🐱‍👤 Laravel - Folder

🌿 Laravel Folder Structure


When you create a new Laravel project, it comes with a structured directory tree. Let’s break down the purpose of each folder and key files:

📁 1. app/

This is the core of your application — where the main business logic lives.

  • Console/ – Contains custom Artisan commands.
  • Exceptions/ – Handles application exceptions.
  • Http/
    • Controllers/ – Controllers that handle request logic.
    • Middleware/ – Middleware for filtering requests (like authentication).
    • Kernel.php – Registers middleware.
  • Models/ – Eloquent models for DB interaction.
  • Providers/ – Service providers to bootstrap services.

📁 2. bootstrap/

  • app.php – Initializes Laravel and loads configuration.
  • cache/ – Contains framework-generated files for performance.

📁 3. config/

Contains configuration files like app.php, database.php, mail.php, etc.

📁 4. database/

  • factories/ – For generating fake data.
  • migrations/ – Define database table schema.
  • seeders/ – Seed default data into DB.

📁 5. public/

The entry point of the application (index.php). Stores static assets like images, CSS, and JS.

📁 6. resources/

  • views/ – Blade templates go here.
  • lang/ – Language files for localization.
  • css/, js/, sass/ – Frontend assets and styles.

📁 7. routes/

  • web.php – Web routes.
  • api.php – API routes.
  • console.php – Artisan command routes.
  • channels.php – Broadcasting channels.

📁 8. storage/

  • app/ – User-uploaded files.
  • logs/ – Application log files.
  • framework/ – Cache, sessions, compiled views.

📁 9. tests/

Contains test cases using PHPUnit.

  • Feature/ – Tests for controllers and routes.
  • Unit/ – Tests for individual components/models.

📁 10. vendor/

Contains Composer-managed packages and dependencies. Don’t edit manually!

📄 Key Files in Root Directory

File Description
.env Environment settings like DB, mail, app name.
.gitignore Tells Git what to ignore.
artisan Laravel's CLI tool.
composer.json Manages PHP dependencies.
package.json Manages frontend assets/tools.
vite.config.js Vite asset bundler configuration.
phpunit.xml Testing config for PHPUnit.

💡 Summary Table

Folder Purpose
app/Application logic, controllers, models
bootstrap/Bootstraps Laravel app
config/Configuration files
database/Migrations, seeders, factories
public/Web entry point, assets
resources/Blade views, assets, translations
routes/Route definitions
storage/Logs, cache, file uploads
tests/Unit and feature tests
vendor/Composer dependencies

Post a Comment

0 Comments