# Running SyncSHOP locally

## First time

```bash
composer setup     # dependencies, .env, app key, migrations, permissions, address data, git hooks, front-end build
php artisan db:seed   # a development owner account (see database/seeders/DatabaseSeeder.php) and an installed shop
```

PostgreSQL 16 or newer and Redis must be running; set their details in `.env` first.

## https://syncshop.test (macOS, Homebrew Apache)

On a Mac with Homebrew Apache, php-fpm and mkcert, `deploy/local/install-vhost.sh` sets up `https://syncshop.test`.
It creates a certificate, installs the vhost, adds the host name and reloads Apache. It asks for `sudo`, so run it
yourself:

```bash
deploy/local/install-vhost.sh
```

Apache's logs for the site go to `storage/logs/apache/`. Set `APP_URL=https://syncshop.test` in `.env`.

Without Apache, `php artisan serve` serves the shop at `http://127.0.0.1:8000`. Set `APP_URL` to match.

## While you work

```bash
composer dev
```

This starts everything the shop needs in one terminal: the queue workers (Horizon), Reverb, the scheduler
(`schedule:work`, so the dashboard stops warning about scheduled tasks), the log viewer (Pail), Vite with hot reload,
and `php artisan serve`.

- **Email:** point `MAIL_MAILER=smtp`, `MAIL_HOST=127.0.0.1` and `MAIL_PORT=1025` at [Mailpit](https://mailpit.axllent.org)
  and read every message the shop sends at `http://localhost:8025`.
- **Realtime:** behind Apache, Reverb listens on `REVERB_SERVER_PORT` (8082 in the vhost) and browsers reach it through
  `wss://syncshop.test/app/…`, with `REVERB_HOST=syncshop.test`, `REVERB_PORT=443` and `REVERB_SCHEME=https`.
- **Two-factor authentication** is required for staff by default. `ADMIN_TWO_FACTOR_REQUIRED=false` turns the
  requirement off on your machine; a release refuses to go live without it (`php artisan app:preflight`).
- **Exchange rates:** `php artisan currency:fetch-rates` fetches the latest BNR rates, and `--year=2025` loads a whole year.
