Project setup and structure

Laravel · Essentials · 10 min

Knowing where things go is the first step to navigating any Laravel codebase.

Create a project with the Laravel installer, laravel new example-app, or with Composer, composer create-project laravel/laravel example-app. The installer can add a starter kit (React, Vue or Livewire) with authentication pages already built. New apps use SQLite by default, so they run with zero database setup.

Start everything for development with composer run dev, which runs the PHP server, the queue worker, log tailing and the Vite asset server together. php artisan serve starts just the web server at http://localhost:8000.

The layout:

  • app/: your code. Http/Controllers, Models, Providers and later Jobs, Policies and so on, all autoloaded under the App\ namespace.
  • bootstrap/app.php: configures routing, middleware and exception handling for the application (Laravel 11+ removed the old HTTP Kernel class).
  • config/: configuration files that read environment values with env().
  • database/: migrations, factories and seeders.
  • public/index.php: the single entry point for every request.
  • resources/: Blade views, CSS and JS. routes/: web.php and console.php (add api.php with php artisan install:api).
  • storage/: logs, cache and uploaded files; tests/: feature and unit tests.

Secrets and per-environment settings live in .env, which is never committed. Artisan, the CLI (php artisan list), generates code (make:controller, make:model), runs migrations and much more.

Example

laravel new example-app          # or: composer create-project laravel/laravel example-app
cd example-app
composer run dev                 # server + queue + logs + Vite in one terminal
# or just: php artisan serve     -> http://127.0.0.1:8000

php artisan --version            # Laravel Framework 12.x
php artisan about                # environment, drivers, cache status
php artisan list make            # all generators

php artisan make:controller PostController
php artisan make:model Post --migration --factory
php artisan tinker               # REPL with the app booted
# > App\Models\User::count()

Remember

  • Create apps with laravel new or composer create-project
  • public/index.php is the only entry point; your code lives in app/
  • Use php artisan for generators, migrations and a Tinker REPL

Watch out for

  • Committing .env with real credentials; only .env.example belongs in Git.

Check yourself

  1. Where is middleware configured in a fresh Laravel 12 app?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: laravel.com/docs/12.x/structure