# Deploying Grace Family Church to a cPanel subdomain (no terminal)

This guide deploys the app to a subdomain (e.g. `https://gfc.yourdomain.com`)
using only cPanel's File Manager + a browser. The bundled `deploy.php` runs the
commands that normally need a terminal (migrations, storage link, caches, seed).

> The ZIP already includes `vendor/` (PHP libraries) and the compiled CSS in
> `public/assets`, so **you do NOT need Composer, npm, or a build step.**

---

## 1. Create the subdomain

cPanel → **Domains / Subdomains** → create `gfc` (or whatever you like).
Note the **Document Root** it gives you, e.g. `/home/cpaneluser/gfc`.

You have two layout choices — **Option A is strongly recommended.**

### Option A (recommended): point the docroot at `/public`
Set the subdomain's **Document Root** to `…/gfc/public`.
Then upload the whole project into `…/gfc/` (so you end up with
`…/gfc/app`, `…/gfc/public`, `…/gfc/vendor`, etc.).
Nothing else to change — Laravel is designed for this.

### Option B: docroot can't be changed
If the host forces the docroot to be the subdomain folder itself, see
**Appendix B** at the bottom.

---

## 2. Create the database (cPanel → MySQL® Databases)

1. **Create New Database** → e.g. `gfc` (cPanel prefixes it, e.g. `cpaneluser_gfc`).
2. **Add New User** → e.g. `gfc` with a strong password.
3. **Add User To Database** → grant **ALL PRIVILEGES**.
4. Write down the final database name, username, and password.

---

## 3. Upload the files

1. cPanel → **File Manager** → go to your subdomain folder (e.g. `…/gfc`).
2. **Upload** `gfc-deploy.zip`.
3. Select it → **Extract** → extract into the subdomain folder.
4. You should now see `app/`, `bootstrap/`, `public/`, `vendor/`, `artisan`, etc.

---

## 4. Configure `.env`

1. In File Manager, enable **Settings → Show Hidden Files (dotfiles)**.
2. Rename **`.env.production`** → **`.env`** (in the project root, next to `artisan`).
3. **Edit** `.env` and set:
   - `APP_URL=https://gfc.yourdomain.com`
   - `DB_DATABASE`, `DB_USERNAME`, `DB_PASSWORD` from step 2
   - `MAIL_*` (your cPanel email account → outgoing/SMTP settings)
   - `DEPLOY_KEY=` a long random string (you'll use it in the next step)
   - Optionally `ADMIN_EMAIL` / `ADMIN_PASSWORD` (your first super-admin login)
   - Leave `APP_KEY=` blank for now.

---

## 5. Run the deployer (in your browser)

Open these URLs one at a time (replace the host + key):

1. **Generate the app key**
   `https://gfc.yourdomain.com/deploy.php?key=YOUR_DEPLOY_KEY&action=appkey`
2. **Deploy** (runs migrations, links storage, clears caches)
   `https://gfc.yourdomain.com/deploy.php?key=YOUR_DEPLOY_KEY&action=deploy`
3. **Seed essentials** (creates your super-admin + site settings)
   `https://gfc.yourdomain.com/deploy.php?key=YOUR_DEPLOY_KEY&action=seed`
4. **Seed demo data (A–Z)** — the realistic content to show the client
   `https://gfc.yourdomain.com/deploy.php?key=YOUR_DEPLOY_KEY&action=seed-demo`
5. *(optional, for speed)* **Cache config/routes/views**
   `https://gfc.yourdomain.com/deploy.php?key=YOUR_DEPLOY_KEY&action=optimize`

Each page shows OK/FAILED with output. Or just open
`…/deploy.php?key=YOUR_DEPLOY_KEY` for a button menu.

> If `storage:link` reports it can't create a symlink, see **Appendix A**.

---

## 6. Lock it down

- **Delete `public/deploy.php`** (File Manager → delete), or blank out `DEPLOY_KEY` in `.env`.
- Confirm `APP_DEBUG=false` and `APP_ENV=production` in `.env`.
- Make sure the site loads over **HTTPS** (cPanel → SSL/TLS Status → run AutoSSL).
  HTTPS is required for the PWA / "install app" / offline features to work.

---

## 7. Log in

- Admin panel: `https://gfc.yourdomain.com/admin/login`
- Email / password: whatever you set in `ADMIN_EMAIL` / `ADMIN_PASSWORD`
  (default if unchanged: `admin@your-domain.co.za` / `ChangeThisStrongPassword!`).
- The demo also creates an **editor** account: `editor@gracefamilychurch.co.za` / `ChangeMe!2026`.

**Change these passwords immediately** under Admin → Profile / Admin Users.

---

## What the demo data includes (to show the client A–Z)

| Area | Demo content |
|------|--------------|
| Home hero | 3-image fading slideshow |
| Sermons | 8 sermons with YouTube links |
| Events | 3 upcoming + 2 past (with images) |
| Blog | 3 published (with covers + comments), 1 scheduled, 1 draft |
| Comments | approved / pending / declined + an admin reply |
| Prayer requests | 7 (public/private, prayed/un-prayed) |
| Contact messages | new / read / replied / archived |
| Leadership | 3 sections with 6 people + photos |
| Service times | Sunday ×2 + Ignite YA |
| Newsletter | 12 subscribers + 8 members |
| Notifications | 4, each deep-linking to its item |
| Activity log | recent admin actions |
| Hero/section images | home, about, services, connect, history |

---

## Updating the site later

Re-upload changed files, then run `?action=deploy` again (and `?action=optimize`
if you use caching). Migrations are safe to re-run — only new ones apply.

---

## Appendix A — storage symlink fallback

The app stores uploaded images in `storage/app/public` and serves them from
`public/storage`. `deploy.php`'s `storage:link` creates that link. If your host
disables PHP symlinks:

- In File Manager, **copy** the folder `storage/app/public` and paste its contents
  into a new folder `public/storage`, **or**
- Ask the host to enable symlinks.

(Uploaded images will 404 until `public/storage` exists.)

## Appendix B — docroot is the subdomain folder (can't point to /public)

1. Upload the project into a folder **above** the web root, e.g. `…/gfc_app`
   (not inside the docroot).
2. Copy everything from `gfc_app/public/` into the subdomain's docroot.
3. Edit the docroot `index.php` and change the two `require` paths to point at
   `gfc_app`, e.g.:
   ```php
   require __DIR__.'/../gfc_app/vendor/autoload.php';
   $app = require_once __DIR__.'/../gfc_app/bootstrap/app.php';
   ```
4. Put `deploy.php` in the docroot too and set, near the top,
   `$base = __DIR__ . '/../gfc_app';` (instead of `dirname(__DIR__)`).
5. Continue from step 4 (configure `.env` inside `gfc_app`).
