LARAVEL

Laravel Directory Structure


The directory structure of a Laravel application is designed to provide organization and maintainability. Here's a typical directory structure of a Laravel application:

laravel-app/
│
├── app/
│   ├── Console/
│   ├── Exceptions/
│   ├── Http/
│   │   ├── Controllers/
│   │   ├── Middleware/
│   │   ├── Requests/
│   │   └── Kernel.php
│   ├── Models/
│   └── Providers/
│
├── bootstrap/
│   └── app.php
│
├── config/
│
├── database/
│   ├── migrations/
│   └── seeders/
│
├── public/
│   └── index.php
│
├── resources/
│   ├── css/
│   ├── js/
│   ├── lang/
│   └── views/
│
├── routes/
│   ├── api.php
│   └── web.php
│
├── storage/
│   ├── app/
│   ├── framework/
│   └── logs/
│
├── tests/
│
├── vendor/
│
├── .env
├── .env.example
├── artisan
└── composer.json

 

1.   app/:  This directory contains the core application code.

  •  Console/: Contains artisan commands.
  • Exceptions/: Holds exception handler classes.
  • Http/: Contains controllers, middleware, form requests, and route definitions.
  • Models/: Houses Eloquent models.
  • Providers/: Contains service providers.
  • bootstrap/: Contains files that bootstrap the Laravel application.
  • app.php: Initializes the Laravel framework.
     

2. config/: Contains configuration files for various aspects of the application.

  • app.php: Application configuration.
  • database.php: Database configuration.
  • mail.php: Mail configuration.
  • services.php: Configuration for third-party services.

3. database/: Contains database-related files such as migrations and seeders.

4. migrations/: Database migration files.
5. seeders/: Database seeder classes.
6. public/: The web server's document root. It contains the entry point to the application and publicly accessible assets.

  • index.php: The entry point for all requests.

7. resources/: Contains non-PHP resources used by the application.

  • css/: CSS files.
  • js/: JavaScript files.
  • lang/: Language files.
  • views/: Blade templates.
     

8. routes/: Contains route definitions for the application.

  • api.php: Routes for API endpoints.
  • web.php: Routes for web pages.

9. storage/: Contains files generated and used by the application such as logs, cache, and uploaded files.

  • app/: Stores files generated by the application.
  • framework/: Stores framework-generated files such as cache and sessions.
  • logs/: Contains application log files.
  • tests/: Contains PHPUnit test cases for testing the application.

10. vendor/: Contains Composer dependencies.

11. .env: Environment configuration file.

12. .env.example: Example environment configuration file.

13. artisan: Command-line utility for interacting with the Laravel application.

 


LARAVEL