# Installation and Verification for Trilok — Revision 03

Review `REVISION_03_MJ_ADMIN.md` and migration `000007` before beginning implementation. These expansion points prevent the Superadmin foundation from blocking the approved MJ Admin workflow later.

## 1. Server prerequisites

- PHP 8.2 or newer with `intl`, `mbstring`, `json`, `mysqlnd`/`mysqli`, `curl`, `fileinfo`, `openssl` and `zip`.
- Composer 2.x.
- MySQL 8.x with InnoDB and `utf8mb4`.
- Apache or Nginx document root pointed to CodeIgniter's `public/` directory.
- HTTPS for every non-local environment.

## 2. Create the clean application

Create an official CodeIgniter appstarter project in the private repository:

```bash
composer create-project codeigniter4/appstarter newb360 "^4.6"
cd newb360
```

Copy this milestone over the appstarter root. Keep the appstarter `spark`, `public/`, `writable/`, `preload.php`, and standard framework configuration files unless this milestone explicitly supplies a replacement.

Then install the declared dependencies:

```bash
composer install
composer require codeigniter4/shield:^1.1
php spark shield:setup
```

If Composer resolves a newer compatible CodeIgniter 4 or Shield version, commit `composer.lock` so development, preproduction and production use the same versions.

## 3. Environment

```bash
cp .env.example .env
```

Set the real URL, database credentials, random encryption key and private OMR token in `.env`. Do not commit `.env`. Point the development site to a professional development subdomain; the temporary server's primary domain does not have to appear in customer URLs.

Create a least-privilege MySQL user for this application only. Do not reuse root or another product's database account.

## 4. Create the schema

```bash
php spark migrate --all
```

Migration `000006_CreateOrganizationMemberships` is additive and must be run even if migrations 000001–000005 were already applied. Do not edit an already-recorded migration in place.

The CodeIgniter migrations are authoritative. Do not manually create or rename application tables. Shield migrations create authentication tables; newB360 migrations create the competition application tables.

## 5. Verify

```bash
composer test
php tools/validate_foundation.py
php spark routes
curl -fsS https://YOUR-DEVELOPMENT-HOST/health
```

Expected validator ending:

```text
PASS: newB360 M1 foundation structure and schema invariants
```

## 6. Environment separation

Use separate databases and `.env` files for development and preproduction. Do not point this milestone at the existing B360 database. Production deployment is a later approval gate.

## 7. Return to Joerg

Please return:

- private repository URL, branch and exact commit;
- resolved PHP, CodeIgniter, Shield, Composer and MySQL versions;
- complete migration and test output;
- the development hostname;
- confirmation that the web root is `public/`;
- confirmation that private uploads are outside `public/`;
- any error or required deviation from the supplied schema.
- confirmation that one test user was assigned to two organizations and received two roles within at least one organization.
