# Felles - cPanel Hosting Deployment Guide

This guide provides step-by-step instructions for deploying Felles to a standard cPanel hosting environment.

---

## 1. System & Server Requirements

- **PHP Version**: `8.2` or `8.3` (Set in cPanel > **Select PHP Version** / **MultiPHP Manager**)
- **Required PHP Extensions**:
  - `bcmath`
  - `ctype`
  - `curl`
  - `dom`
  - `fileinfo`
  - `json`
  - `mbstring`
  - `openssl`
  - `pdo` & `pdo_sqlite` (or `pdo_mysql` if using MySQL)
  - `tokenizer`
  - `xml`
  - `zip`

---

## 2. Deployment Architecture Options

### Option A: Standard DocumentRoot Separation (Most Secure & Recommended)
1. In cPanel **File Manager**, create a folder in your home directory (e.g. `/home/username/felles_core`).
2. Upload all project files into `/home/username/felles_core/` **except** the `public` folder.
3. Upload the contents of the project's `public/` directory directly into `/home/username/public_html/`.
4. Edit `/home/username/public_html/index.php` and update the paths:
   ```php
   // Change from:
   require __DIR__.'/../vendor/autoload.php';
   $app = require_once __DIR__.'/../bootstrap/app.php';

   // To:
   require __DIR__.'/../felles_core/vendor/autoload.php';
   $app = require_once __DIR__.'/../felles_core/bootstrap/app.php';
   ```

### Option B: Single Directory Deployment (Using Root .htaccess)
1. Upload the entire project directory into `/home/username/public_html/`.
2. The included root `.htaccess` will automatically rewrite all requests to `/public/` and block access to `.env`, `database/`, and `storage/`.

---

## 3. Environment & Configuration (.env)

1. Copy `.env.production.example` to `.env`:
   ```bash
   cp .env.production.example .env
   ```
2. Configure your live domain, database, and email settings:
   ```env
   APP_NAME="Felles"
   APP_ENV=production
   APP_DEBUG=false
   APP_URL=https://felles.xyz

   # Database (SQLite by default or MySQL)
   DB_CONNECTION=sqlite

   # SMTP Mail Settings (for Email OTP verification)
   MAIL_MAILER=smtp
   MAIL_HOST=mail.felles.xyz
   MAIL_PORT=465
   MAIL_USERNAME=support@felles.xyz
   MAIL_PASSWORD=your_email_password
   MAIL_ENCRYPTION=ssl
   MAIL_FROM_ADDRESS="support@felles.xyz"
   MAIL_FROM_NAME="Felles Support"
   ```
3. Generate application key:
   ```bash
   php artisan key:generate
   ```

---

## 4. File & Directory Permissions

Ensure web server write permissions on:
- `storage/` & all subdirectories &rarr; `775`
- `bootstrap/cache/` &rarr; `775`
- `database/database.sqlite` (if using SQLite) &rarr; `664` or `775`
- `public/uploads/` &rarr; `775`
- All other directories &rarr; `755`
- All other files &rarr; `644`

---

## 5. Storage Symlink & Cron Setup

1. **Storage Symlink**:
   ```bash
   php artisan storage:link
   ```
2. **cPanel Cron Job**:
   In cPanel > **Cron Jobs**, add a cron job running every minute:
   ```cron
   * * * * * cd /home/username/felles_core && php artisan schedule:run >> /dev/null 2>&1
   ```

---

## 6. Production Cache & Optimization

Run these commands in cPanel Terminal (or SSH):
```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

---

## 7. Clean Database State & Admin Login

The production database has been cleaned of all test/dummy data.
- **Admin Login URL**: `https://felles.xyz/login`
- **Default Administrator Account**: `admin@platform.com` (or your configured admin account)
- **Role**: `admin`
- **First Step**: Log into the Admin Panel at `/admin` and update your password under Profile settings.
