# Installation Guide (Newsgate / CodeIgniter 4)

This project is designed to be installed via the built-in **web installer**.

## Requirements

- **PHP**: 7.3+ (8.x is supported)
- **Extensions**: cURL, fileinfo, mbstring, GD, intl, json
- **Database**: MySQL/MariaDB (MySQLi)
- **Web server**: Apache with `mod_rewrite` enabled

## Files you must have in place

- **Root `.env` must exist and be writable**
  - Create it from `env.example`:
    - `cp env.example .env`
  - Ensure it’s writable (the installer checks this).

## Folder permissions (must be writable by PHP)

The installer checks these paths:

- `writable/`
- `uploads/audios/`
- `uploads/blocks/`
- `uploads/files/`
- `uploads/gallery/`
- `uploads/images/`
- `uploads/logo/`
- `uploads/profile/`
- `uploads/quiz/`
- `uploads/thumbnails/`
- `uploads/tmp/`
- `uploads/videos/`

## Install steps (recommended)

1. **Upload** the project to your hosting (or ensure it’s already in place).
2. **Create** your database and user in MySQL/MariaDB (or have credentials ready).
3. **Create `.env`**:
   - `cp env.example .env`
4. **Open installer** in your browser:
   - `/install/`
5. Follow the installer:
   - **System Requirements**
   - **Folder Permissions**
   - **Database**
   - **Settings + Admin account**

## What the installer changes

- Writes DB credentials to: `app/Config/Database.php`
- Imports schema/data from: `install/sql/install_newsgate.sql`
  - In this repo, the canonical SQL dump is `install/sql/install_varient.sql`.
  - A copy named `install/sql/install_newsgate.sql` is provided because the installer expects that filename.
- Writes `.env` with:
  - `CI_ENVIRONMENT = production`
  - `app.baseURL = ...`
  - `PURCHASE_CODE`, `LICENSE_KEY`
  - `cookie.prefix = 'vr'`

## After install (must do)

- **Remove or block** the `install/` directory.
  - At minimum, protect it behind auth or IP allow-list.
- Confirm:
  - `writable/` is **not publicly accessible** (it ships with a deny `.htaccess`)
  - HTTPS redirect behavior matches your hosting (see `docs/OPERATIONS.md`)

