# eSignify — Installation Guide

## Quick start

1. **Upload files** to your server's `public_html/` (or set `public/` as the document root)

2. **Make directories writable:**
   ```bash
   chmod -R 755 storage/
   chmod 755 config/
   ```

3. **Create MySQL database** (or let the wizard do it):
   - In cPanel → MySQL Databases → create database + user + assign privileges
   - User needs: CREATE, ALTER, INSERT, UPDATE, DELETE, SELECT

4. **Visit the wizard:**
   ```
   https://yourdomain.com/install/
   ```
   The wizard will:
   - Check PHP requirements
   - Connect to your database and import the schema
   - Write `config/db.php`, `config/mail.php`, `config/app.php`
   - Create your superadmin account
   - Write `storage/.installed` to lock itself out

5. **Install PHP dependencies** (if Composer is available):
   ```bash
   composer require phpmailer/phpmailer dompdf/dompdf setasign/fpdi
   ```
   On shared hosting without Composer, upload the vendor/ folder separately.

6. **Add cron jobs in cPanel:**
   ```
   * * * * *    php /home/USER/esignify.net/cron.php email   >> /dev/null 2>&1
   * * * * *    php /home/USER/esignify.net/cron.php webhook >> /dev/null 2>&1
   0 * * * *    php /home/USER/esignify.net/cron.php reminder >> /dev/null 2>&1
   */15 * * * * php /home/USER/esignify.net/cron.php expiry  >> /dev/null 2>&1
   */5  * * * * php /home/USER/esignify.net/cron.php bulk    >> /dev/null 2>&1
   ```

7. **Configure Stripe** (for billing):
   - Edit `config/stripe.php` with your keys and price IDs
   - Add webhook in Stripe Dashboard → `https://yourdomain.com/billing/webhook`
   - Events to enable: `checkout.session.completed`, `customer.subscription.*`,
     `invoice.payment_succeeded`, `invoice.payment_failed`,
     `customer.subscription.trial_will_end`

8. **Optional — PDF rendering:**
   - Enable `php-imagick` extension in cPanel PHP settings
   - Enables real PDF page rendering in the builder and signing page

9. **Optional — Document conversion (DOCX → PDF):**
   - On VPS: install Gotenberg Docker container on port 3000
   - On shared hosting: add `CLOUDCONVERT_API_KEY` in `config/app.php`

## Reinstalling

To re-run the wizard: delete `storage/.installed`

## Manual configuration

If the wizard can't write config files, set them manually:

- `config/db.php` — database credentials
- `config/mail.php` — SMTP settings
- `config/stripe.php` — Stripe keys
- `config/app.php` — APP_NAME, APP_URL, APP_ENV

Then import `config/schema.sql` to your database and run:
```sql
UPDATE users SET is_superadmin = 1 WHERE email = 'your@email.com';
```

## Requirements

| | Minimum | Recommended |
|---|---|---|
| PHP | 8.1 | 8.3 |
| MySQL | 5.7 | 8.0 |
| Memory | 128MB | 256MB |
| Upload | 25MB | 50MB |
| Extensions | pdo, pdo_mysql, openssl, mbstring, curl, fileinfo, json | + imagick, gd, zip |
