# Install on XAMPP (localhost)

Follow these steps to run Prep on your Windows/macOS/Linux machine using XAMPP.

---

## 1. Prerequisites

- [XAMPP](https://www.apachefriends.org/) installed (PHP 8.1+)
- [Composer](https://getcomposer.org/download/) installed
- [Git](https://git-scm.com/) (optional — or download the project as ZIP)

---

## 2. Clone or copy the project

```bash
cd C:\xampp\htdocs
git clone <your-repo-url> prep
```

Or extract the project ZIP into `C:\xampp\htdocs\prep`.

---

## 3. Install PHP dependencies

Open a terminal in `C:\xampp\htdocs\prep` and run:

```bash
composer install
```

---

## 4. Create the .env file

```bash
copy .env.example .env
```

Edit `.env` and fill in your values:

```env
APP_ENV=local
APP_URL=http://localhost/prep

DB_HOST=localhost
DB_NAME=prep
DB_USER=root
DB_PASS=

AI_PROVIDER=openai
AI_API_KEY=sk-your-key-here
AI_BASE_URL=https://api.openai.com/v1
AI_MODEL=gpt-4o
```

---

## 5. Create the database

Open **phpMyAdmin** at [http://localhost/phpmyadmin](http://localhost/phpmyadmin), then:

1. Click **New** in the left sidebar
2. Database name: `prep`
3. Collation: `utf8mb4_unicode_ci`
4. Click **Create**

Then import the schema:

1. Select the `prep` database
2. Click the **Import** tab
3. Choose `database/schema.sql` from the project folder
4. Click **Go**

---

## 6. Set up the storage directory

```bash
mkdir storage\uploads
```

Make sure the directory is writable. On Windows with XAMPP, this is usually automatic. On macOS/Linux:

```bash
chmod -R 755 storage
chmod -R 775 storage/uploads
```

---

## 7. Start Apache and MySQL

Open the **XAMPP Control Panel** and click **Start** for both Apache and MySQL.

---

## 8. Open the app

Visit [http://localhost/prep/public](http://localhost/prep/public)

---

## 9. Run tests

```bash
php tests/run.php
php tests/e2e-test.php
```

All tests should pass. If you have an API key set, run:

```bash
php tests/provider-test.php deepseek
```

---

## Troubleshooting

| Problem | Solution |
|---------|----------|
| "Class not found" error | Run `composer dump-autoload` |
| "Connection refused" for MySQL | Make sure MySQL is running in XAMPP Control Panel |
| Upload fails | Check `storage/uploads/` is writable |
| 404 on `/prep/public` | Make sure `mod_rewrite` is enabled in Apache |
| "cURL extension is not loaded" | Enable `php_curl` in `php.ini` (XAMPP includes it by default) |
| "fileinfo extension not loaded" | Enable `php_fileinfo` in `php.ini` |
