# Deploying Furnitec to EBN Host (cPanel Shared Hosting)

## Requirements
- PHP **8.2+** (set in cPanel → *Select PHP Version*). Enable extensions: `pdo_mysql`, `mbstring`, `openssl`, `ctype`, `fileinfo`, `tokenizer`, `xml`.
- One MySQL database.

## Step 1 — Build locally (already done)
The repo already contains the compiled assets in `public/build/`. If you ever change
CSS/JS, run `npm run build` locally before uploading — **no Node.js is needed on the server**.

## Step 2 — Create the database in cPanel
1. cPanel → **MySQL Databases** → create database (e.g. `youruser_furnitec`).
2. Create a DB user with a strong password and give it **All Privileges** on that database.

## Step 3 — Upload the files
Recommended layout (keeps the app code outside the web root):

```
/home/youruser/
├── furnitec/          ← everything in this project EXCEPT public/
└── public_html/       ← the CONTENTS of this project's public/ folder
```

1. Zip the project locally, upload via cPanel **File Manager**, extract to `~/furnitec`.
2. Move the contents of `~/furnitec/public/` into `~/public_html/`.
3. Edit `~/public_html/index.php` and change the two paths:

```php
require __DIR__.'/../furnitec/vendor/autoload.php';
$app = require_once __DIR__.'/../furnitec/bootstrap/app.php';
```

> Alternative (quicker, slightly less tidy): upload the whole project into
> `~/furnitec` and point the domain's document root at `~/furnitec/public`
> (cPanel → Domains → Manage → Document Root).

## Step 4 — Configure the environment
Copy `.env.example` to `.env` inside `~/furnitec` and set:

```dotenv
APP_NAME=Furnitec
APP_ENV=production
APP_DEBUG=false
APP_URL=https://furnitecbd.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=youruser_furnitec
DB_USERNAME=youruser_dbuser
DB_PASSWORD=********

SESSION_DRIVER=file
CACHE_STORE=file
QUEUE_CONNECTION=sync
```

Generate an app key. With cPanel **Terminal** (or SSH):

```bash
cd ~/furnitec
php artisan key:generate
```

(No terminal? Run `php artisan key:generate --show` locally and paste the value
into `APP_KEY=` manually.)

## Step 5 — Create the tables and load the catalog
With cPanel Terminal:

```bash
cd ~/furnitec
php artisan migrate --force
php artisan db:seed --class=CatalogSeeder --force
```

(No terminal? Export your **local** `furnitec` database from phpMyAdmin and import
the .sql file into the live database via cPanel phpMyAdmin — same result.)

## Step 6 — Product images
Product images currently point to `https://furnitecbd.com/wp-content/uploads/...`.

- **If the new site replaces the old one on the same hosting:** keep the old
  `wp-content/uploads` folder in `public_html` — images keep working unchanged. Done.
- **To make the site fully self-contained** (recommended long-term), run once:

```bash
php artisan furnitec:localize-images
```

This downloads every image into `public/images/products/` and rewrites the database
URLs. Run it **before** deleting the old WordPress files.

## Step 7 — Final optimisation

```bash
cd ~/furnitec
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

Re-run these three commands any time you edit `.env` or routes.

## Checking orders & messages
Customer orders land in the `orders` / `order_items` tables and contact-form
messages in `contact_messages` — view them in phpMyAdmin. (A small admin panel
is a good next step — ask Claude to build one.)

## Troubleshooting
| Symptom | Fix |
|---|---|
| 500 error after upload | Check `storage/` and `bootstrap/cache/` are writable (755/775); check `.env` exists and `APP_KEY` is set. |
| Blank styles | `public/build/` folder missing — re-upload it. |
| "No application encryption key" | Run `php artisan key:generate` (or paste a key manually). |
| DB connection refused | Use `localhost` as `DB_HOST` on shared hosting, not 127.0.0.1. |
| Old page cached | `php artisan config:clear && php artisan view:clear` |
