Root Directory
After running laravel new project-name or composer create-project, youβll see several folders and files in the root of your Laravel project. Letβs look at the most important ones:
app/ β Contains your application logic (models, controllers, middleware, etc.)
bootstrap/ β Bootstraps the framework and loads configuration.
config/ β Holds configuration files for database, mail, cache, etc.
database/ β Contains migrations, seeders, and factories for database setup.
public/ β The only folder accessible from the web; contains index.php, CSS, JS, images.
resources/ β Holds Blade templates, raw assets (CSS, JS), and language files.
routes/ β All application routes are defined here (web.php, api.php, etc.)
storage/ β Stores logs, cached views, file uploads, and compiled Blade templates.
tests/ β Contains automated tests (unit and feature).
vendor/ β Composer dependencies (do not edit manually).
The app/ Folder
This is where most of your applicationβs core logic lives. Inside, youβll find:
- Console/ β Custom Artisan commands.
- Exceptions/ β Handles application exceptions.
- Http/ β Contains controllers, middleware, and request classes.
- Models/ β Default location for Eloquent models.
- Providers/ β Service providers that bootstrap services.
The routes/ Folder
Laravel keeps all route definitions in one place:
- web.php β Routes for web (frontend), uses sessions & CSRF protection.
- api.php β Routes for APIs, stateless by default.
- console.php β Define Artisan commands here.
- channels.php β Routes for event broadcasting (WebSockets).
Example from web.php:
Route::get('/', function () {
return view('welcome');
});
The resources/ Folder
This folder is all about user-facing content:
- views/ β Blade templates (.blade.php files).
- lang/ β Language/localization files.
- js/, css/ β Frontend assets (before compilation with Laravel Mix or Vite).
Example Blade file in resources/views/home.blade.php:
<!DOCTYPE html>
<html>
<head>
<title>Home Page</title>
</head>
<body>
<h1>Welcome to Laravel!</h1>
</body>
</html>
The database/ Folder
This is where you define and manage your database schema:
- migrations/ β Files that create/modify database tables.
- seeders/ β Pre-fill tables with sample data.
- factories/ β Generate fake data for testing.
Example migration:
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->timestamps();
});
}
The config/ Folder
All configuration lives here:
- app.php β Application settings
- database.php β Database connections
- mail.php β Email configuration
- cache.php β Cache settings
Instead of hardcoding settings, you can change them here once and use them across the app.
The storage/ Folder
This folder handles all the "temporary" and "generated" files:
- logs/ β Application logs.
- framework/ β Compiled views, cache, and sessions.
- app/ β File uploads (user images, docs, etc.).
Important: Always give write permissions to storage/ when deploying.
The public/ Folder
The entry point of your application.
- index.php β Boots up Laravel and handles all requests.
- Assets like css/, js/, and images/.
Never expose other folders to the public web β only this one!