# XAMPP Deployment Guide

## Prerequisites

- XAMPP 8.2+ installed (includes Apache, MySQL, PHP, phpMyAdmin)
- Windows, macOS, or Linux

## Step-by-Step Setup

### 1. Start XAMPP Services

Open XAMPP Control Panel and start:
- **Apache**
- **MySQL**

### 2. Place Project Files

Copy the entire `AiWebReporter` folder to:
- **Windows**: `C:\xampp\htdocs\AiWebReporter\`
- **macOS**: `/Applications/XAMPP/htdocs/AiWebReporter/`
- **Linux**: `/opt/lampp/htdocs/AiWebReporter/`

### 3. Create Database

1. Open phpMyAdmin: `http://localhost/phpmyadmin`
2. Click **New** in the left sidebar
3. Database name: `aiwebreporter`
4. Collation: `utf8mb4_unicode_ci`
5. Click **Create**

### 4. Run Migrations

1. In phpMyAdmin, select the `aiwebreporter` database
2. Click the **SQL** tab
3. Open and paste each migration file in order:
   - `database/migrations/001_schema.sql`
   - `database/migrations/002_categories_seed.sql`
   - `database/migrations/003_bot_system.sql`
   - `database/migrations/004_newsletter_system.sql`
   - `database/migrations/005_static_pages.sql`
4. Click **Go** after each one

### 5. Configure Application

Edit `config/config.php`:

```php
'app' => [
    'url'   => 'http://localhost/AiWebReporter',
    'debug' => true,
],
'db' => [
    'host' => 'localhost',
    'name' => 'aiwebreporter',
    'user' => 'root',
    'pass' => '',         // XAMPP default is empty
],
```

### 6. Enable mod_rewrite

XAMPP usually has mod_rewrite enabled. If URLs return 404:

1. Open `C:\xampp\apache\conf\httpd.conf`
2. Find `#LoadModule rewrite_module modules/mod_rewrite.so`
3. Remove the `#` to uncomment it
4. Find the `<Directory>` block for htdocs and ensure `AllowOverride All`
5. Restart Apache

### 7. Test the Site

- Homepage: `http://localhost/AiWebReporter/`
- Admin login: `http://localhost/AiWebReporter/login`

### 8. Upload Directory Permissions

On Windows/XAMPP, file permissions are typically not an issue. On macOS/Linux:

```bash
chmod -R 755 /opt/lampp/htdocs/AiWebReporter/public/uploads/
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Blank page | Enable `display_errors` in php.ini or set `debug => true` in config |
| 404 on all routes | Enable mod_rewrite and ensure AllowOverride All |
| Database connection error | Verify MySQL is running and credentials match config |
| Upload fails | Check `public/uploads/` directory exists and is writable |
| Session errors | Ensure PHP session save path is writable |
