# Environment & Configuration

## Configuration File

All settings are in `config/config.php`, which returns a PHP array.

## Configuration Sections

### `app` — Application Settings

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `name` | string | `'AI Web Reporter'` | Site name used in titles and emails |
| `url` | string | `'http://localhost/AiWebReporter'` | Base URL without trailing slash |
| `debug` | bool | `true` | Show errors (true=dev, false=prod) |
| `timezone` | string | `'UTC'` | PHP timezone for dates |

### `db` — Database Connection

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `host` | string | `'localhost'` | MySQL host |
| `name` | string | `'aiwebreporter'` | Database name |
| `user` | string | `'root'` | Database username |
| `pass` | string | `''` | Database password |
| `charset` | string | `'utf8mb4'` | Connection charset |

### `session` — Session Configuration

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `name` | string | `'AIWR_SESSION'` | Session cookie name |
| `lifetime` | int | `7200` | Session lifetime in seconds |
| `secure` | bool | `false` | Require HTTPS for cookie |
| `httponly` | bool | `true` | JavaScript cannot access cookie |
| `samesite` | string | `'Lax'` | SameSite cookie policy |

### `mail` — SMTP Configuration

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `host` | string | `''` | SMTP server hostname |
| `port` | int | `587` | SMTP port (587=TLS, 465=SSL) |
| `username` | string | `''` | SMTP username |
| `password` | string | `''` | SMTP password |
| `encryption` | string | `'tls'` | Encryption type (tls/ssl) |
| `from_email` | string | | Default sender email |
| `from_name` | string | | Default sender name |

When SMTP is not configured (empty host), the newsletter system auto-confirms subscriptions instead of sending verification emails.

## Environment-Specific Settings

### Development (XAMPP)
```php
'debug' => true,
'url' => 'http://localhost/AiWebReporter',
'secure' => false,
'mail.host' => '',  // Empty = skip emails
```

### Production (cPanel)
```php
'debug' => false,
'url' => 'https://yourdomain.com',
'secure' => true,
'mail.host' => 'mail.yourdomain.com',
```

## Key Behavior Differences

| Setting | Effect when ON | Effect when OFF |
|---------|---------------|-----------------|
| `debug` | Shows PHP errors, stack traces | Logs errors, shows 500 page |
| `session.secure` | Cookie only sent over HTTPS | Cookie sent on HTTP too |
| `mail.host` (set) | Sends verification emails | Auto-confirms subscribers |
