# cPanel Deployment Guide

## 1. Upload Project

Upload and extract the project outside `public_html` where possible:

```text
/home/CPANEL_USER/belar-score-saas
```

## 2. Point the Domain to `/public`

Set the subdomain document root to:

```text
/home/CPANEL_USER/belar-score-saas/public
```

Recommended domain:

```text
mybelarscore.com
```

Do not expose the Laravel root folder directly through the web.

## 3. Install Dependencies

Open cPanel Terminal:

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

## 4. Create MySQL Database

Create:

- Database
- Database user
- Assign all privileges

Update `.env`:

```env
APP_ENV=production
APP_DEBUG=false
APP_URL=https://mybelarscore.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=cpanelprefix_belar_score
DB_USERNAME=cpanelprefix_belar_user
DB_PASSWORD=STRONG_PASSWORD

SESSION_SECURE_COOKIE=true
```

## 5. Run Database Setup

```bash
php artisan migrate --seed --force
php artisan storage:link
php artisan optimize
```

## 6. Folder Permissions

```bash
chmod -R 775 storage bootstrap/cache
```

## 7. Email

Replace the log mailer with the hosting SMTP credentials in `.env`:

```env
MAIL_MAILER=smtp
MAIL_HOST=mail.yourdomain.com
MAIL_PORT=587
MAIL_USERNAME=hello@yourdomain.com
MAIL_PASSWORD=EMAIL_PASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@yourdomain.com
MAIL_FROM_NAME="BELAR Score"
```

## 8. Production Cleanup

- Change all demo passwords.
- Remove demo users and assessment if not needed.
- Set `APP_DEBUG=false`.
- Enable SSL.
- Create daily MySQL and storage backups.
- Add a cron job for Laravel scheduler when scheduled tasks are added later.
