Directory Structure
Relevant source files
The following files were used as context for generating this wiki page:
Laravel follows a specific structural convention designed to separate configuration, application logic, public assets, and database management. The project serves as a skeleton for web applications, providing a standardized organization for PHP code, frontend resources, and automated tests.
The core of the structure is defined by PSR-4 autoloading rules which map the App\ namespace to the app/ directory, while database components like factories and seeders reside in the database/ directory.
Sources: composer.json:28-32, README.md:16-25
Core Application Directories
app/
The app/ directory contains the core code of the application. It is PSR-4 autoloaded under the App namespace. It typically houses controllers, models, and other business logic components.
Sources: composer.json:29, phpunit.xml:18-20
bootstrap/
This directory contains files that initialize the framework. The app.php file is responsible for configuring the application instance, defining routing paths (web, commands, health), and setting up middleware and exception handling.
The bootstrap process links the application to its root directory and prepares the request handling environment.
Sources: bootstrap/app.php:1-17, public/index.php:17-20
config/
The config/ directory contains all of the application's configuration files. These files allow developers to define settings for various services such as the application name, environment, database connections, and file systems.
| Configuration File | Primary Purpose | Key Elements |
|---|---|---|
app.php | Global App Settings | Name, Env, Debug, URL, Timezone, Locale |
database.php | Connection Management | Drivers (SQLite, MySQL, Postgres), Redis config |
filesystems.php | Storage Management | Local, Public, and S3 disk configurations |
Sources: config/app.php:1-105, config/database.php:1-178, config/filesystems.php:1-82
Data and Assets
database/
This directory houses database-related files. It includes a migrations/ subdirectory for schema definitions, such as user tables, cache tables, and job queues. It also contains the default SQLite database file when used.
- Migrations: Found in
database/migrations/, these define the schema for tables likeusers,sessions,jobs, andcache. - Factories/Seeders: Autoloaded for generating and injecting dummy data.
Sources: database/migrations/0001_01_01_000000_create_users_table.php:1-49, composer.json:30-31, composer.json:67
public/
The public/ directory is the entry point for all requests entering the application. It contains the index.php file, which serves as the front controller. It also hosts compiled assets like JavaScript and CSS, and the hot file used for Vite's Hot Module Replacement.
Sources: public/index.php:1-22, resources/views/welcome.blade.php:16-18
resources/
Contains uncompiled frontend assets and view templates.
resources/views/: Blade templates such aswelcome.blade.php.resources/css/: Source CSS files (e.g.,app.css).resources/js/: Source JavaScript files (e.g.,app.js).
Sources: resources/views/welcome.blade.php:1-445, resources/css/app.css:1-13, vite.config.js:7-10
Development and Build Tools
The project root contains various configuration files for the development environment and build pipeline.
The build process uses Vite to compile frontend assets located in resources/ into the public/ directory for production use.
Sources: vite.config.js:1-22, package.json:5-8, resources/css/app.css:3-7
Testing
Tests reside in the tests/ directory, split into Unit and Feature suites. The phpunit.xml file configures the testing environment, often using an in-memory SQLite database.
Sources: phpunit.xml:1-36, composer.json:35
Summary of Root Files
| File | Description |
|---|---|
composer.json | Defines PHP dependencies, namespaces, and lifecycle scripts. |
package.json | Defines Node.js dependencies and frontend build scripts. |
vite.config.js | Configuration for the Vite build tool and Laravel plugin. |
phpunit.xml | Configuration for the PHPUnit testing framework. |
README.md | Provides an overview and links to framework documentation. |
Sources: composer.json:1-81, package.json:1-16, vite.config.js:1-22, phpunit.xml:1-36, README.md:1-58