> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prvue.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel Example

> Example Laravel repo with PostgreSQL, Redis, and .env for preview-deployer

This example uses the **supported** Laravel framework. The orchestrator has a built-in template; you add `preview-config.yml` and optionally build/startup commands for migrations and seeding.

## Repository

* **Repo**: [laravel-project-preview-example](https://github.com/your-org/laravel-project-preview-example) — replace with your repo URL when published.

## Stack

* **Framework**: Laravel (PHP)
* **Database**: PostgreSQL
* **Cache**: Redis
* **Config**: `.env` (e.g. `DB_*`, `REDIS_*`)
* **Health**: `GET /up` (Laravel built-in), `GET /api/health` (JSON with DB + Redis checks)
* **Endpoints**: `GET /api/version`, `GET /api/users/count`

## Key files

### `preview-config.yml` (repository root)

```yaml theme={null}
framework: laravel
database: postgres
health_check_path: /up
# Or use /api/health if you prefer the JSON health endpoint
# health_check_path: /api/health
app_port: 8000
app_port_env: PORT
app_entrypoint: php artisan serve
# (app_entrypoint is required but Laravel always uses php artisan serve)
build_commands:
  - cp .env.example .env
  - php artisan key:generate
startup_commands:
  - php artisan migrate --force
  - php artisan db:seed --force
extra_services:
  - redis
```

The orchestrator generates `docker-compose.preview.yml` from the Laravel template. Ensure `.env` is created before `docker compose up` (e.g. via `build_commands`); set `DB_*` and `REDIS_*` to match the compose services (e.g. `db`, `redis`).

### Optional: `docker-compose.preview.yaml`

If the repo already has a `docker-compose.preview.yml` or `docker-compose.preview.yaml`, the orchestrator uses it and injects host ports for `app` and `db`. Otherwise the built-in Laravel template is used.

## Local run and API

See the repo README for:

* Copy `.env.example` to `.env`, set `DB_*` and `REDIS_*`, run `php artisan key:generate`
* Migrations and seed: `php artisan migrate --force && php artisan db:seed --force`
* `php artisan serve` or Docker Compose

API: `GET /up`, `GET /api/health`, `GET /api/version`, `GET /api/users/count`.
