# Verifield — cPanel Deployment Guide (Truehost Shared Hosting)

**Phase 2 build:** Laravel 12 · Livewire 3 · Tailwind (CDN, no build step) · MySQL.
Redis/Docker from the original plan are swapped for database drivers — everything runs on shared hosting.

---

## 0. What's in this zip

The zip contains the app **without** the `vendor/` folder (Composer dependencies).
You install them once in Step 4. Everything else is upload-and-go.

---

## 1. Set PHP version

cPanel → **MultiPHP Manager** → set your domain to **PHP 8.3 or 8.4** (8.2 minimum).
Then cPanel → **Select PHP Version → Extensions** and make sure these are ON:
`pdo_mysql, mbstring, openssl, tokenizer, xml, ctype, json, fileinfo, bcmath, curl, zip`

## 2. Create the database

cPanel → **MySQL Databases**:
1. Create database, e.g. `youruser_verifield`
2. Create a DB user with a strong password
3. Add the user to the database with **ALL PRIVILEGES**

## 3. Upload and extract

cPanel → **File Manager**:
1. Upload `verifield.zip` to your **home directory** (`/home/youruser/`) — **not** inside `public_html`
2. Right-click → Extract. You now have `/home/youruser/verifield/`

### Point your domain at `verifield/public`

**Option A — subdomain or addon domain (easiest):**
When creating it, set Document Root to `verifield/public`. Done.

**Option B — main domain (cPanel won't let you change its docroot):**
1. In File Manager, move everything **inside** `verifield/public/` into `public_html/`
   (including the hidden `.htaccess` — enable "Show Hidden Files" in settings)
2. Edit `public_html/index.php` and change the two paths:
   ```php
   require __DIR__.'/../verifield/vendor/autoload.php';
   $app = require_once __DIR__.'/../verifield/bootstrap/app.php';
   ```
   (and the maintenance line to `__DIR__.'/../verifield/storage/framework/maintenance.php'`)

## 4. Install dependencies + configure

Open cPanel → **Terminal** (Truehost includes this on most plans), then:

```bash
cd ~/verifield
cp .env.example .env
composer install --no-dev --optimize-autoloader
php artisan key:generate
```

Now edit `.env` (File Manager → Edit): set `APP_URL`, the three `DB_*` values from Step 2,
your SMTP mail settings (create `no-reply@yourdomain` in cPanel → Email Accounts first),
and change `ADMIN_EMAIL` / `ADMIN_PASSWORD`.

Then:

```bash
php artisan migrate --seed --force
php artisan storage:link
php artisan config:cache && php artisan route:cache && php artisan view:cache
```

**No Terminal on your plan?** Run `composer install --no-dev` on your laptop (same PHP major version),
re-zip the folder *with* `vendor/`, and upload that instead. Everything else is identical.

## 5. Cron (queues + scheduler) — one line

cPanel → **Cron Jobs** → add, running **every minute**:

```
* * * * * /usr/local/bin/php /home/youruser/verifield/artisan schedule:run >> /dev/null 2>&1
```

This single entry also drains the email/notification queue (the scheduler runs
`queue:work --stop-when-empty` internally each minute).

## 6. Smoke test

1. Visit your domain → landing page loads, dark-mode toggle works
2. **Create an account** → verification email arrives → click link → dashboard
3. **Security** → set up two-factor → scan QR → confirm → save recovery codes
4. Sign out, sign in → 2FA challenge appears
5. Sign in as the seeded admin → **Admin** link appears in the nav

## 7. If something breaks

- White page / 500 → set `APP_DEBUG=true` in `.env` temporarily, then
  `php artisan config:clear`, reload, read the error, fix, set back to `false`
- Emails not arriving → test the mailbox from cPanel webmail first; port 465/ssl vs 587/tls
- After ANY `.env` change → `php artisan config:cache`
- Logs live at `storage/logs/laravel.log`

## Notes for later phases

- Tailwind runs from CDN in Phase 2 so there's zero Node build on shared hosting.
  Phase 6 (hardening) swaps it for a compiled, purged stylesheet.
- Search in Phase 3 will use MySQL FULLTEXT (not Meilisearch) to stay shared-hosting friendly.
