Laravel Application Directory Structure

Laravel Application Directory Structure

Here we are going to talk a bit about the built of the Laravel application and how files and folders are sorted.

/app_root/.envVery important file, contains all the environment variables and sensitive data necessary to run the app such as MySQL database credentials, Mail server details and AWS details. (should git-ignored) if we plan to share the code online.
  
/app_root/app/all Models in the app live directly under this directory
  
/app_root/app/Http/Controllers/all Controllers of the app live under this directory
/app_root/app/Http/Middlewarethis is the home of the URLS traffic guard, to filter out unauthorised requests and throw 403 error
  
/app_root/config/database.phpfor DB connection details
/app_root/config/filesystems.phpidentify services like S3 cloud configuration
  
/approotdirectory/Database/factories/  to create mock data for testing
/approotdirectory/Database/migrations/to create tables and columns
  
/approotdirectory/public/home of the app for public access
/approotdirectory/public/.htaccessredirect all traffic to index.php
/approotdirectory/public/index.phpprocessing of all traffic starts here
/approotdirectory/public/robots.txtinstructions for search engine spiders
/approotdirectory/public/css/app.csscompiled .css styling files
  
/approotdirectory/resources/views         all blades (Views) live under this directory
  
/approotdirectory/routes/web.phpfor ROUTING traffic from the internet space to controllers in the file system
  
/approotdirectory/storagethe default uploaded files home (within sub-folders)
  
/approotdirectory/storage/logs/laravel.log          Laravel log file to hold errors or whatever we want (ie emails for testing)