# FieldOps Cloud Commands

Exact local commands for the PHP/XAMPP development and QA workflow.

## Working Directory

```powershell
cd 'C:\Users\chama\OneDrive\Documents\FieldOps Cloud'
```

## Local URLs

- XAMPP web app: `http://localhost/FieldOps-Cloud/public`
- Tenant demo entry: `http://localhost/FieldOps-Cloud/public/demo/company-admin`
- Platform admin demo entry: `http://localhost/FieldOps-Cloud/public/demo/platform-admin`
- Platform admin console: `http://localhost/FieldOps-Cloud/public/platform-admin`

## PHP And Composer

Use the project-local Composer scripts when `php` and `composer` are on PATH:

```powershell
composer install --no-interaction --no-progress
composer validate --no-check-publish
composer audit
composer test
$env:COMPOSER_PROCESS_TIMEOUT='0'; composer check
```

Use XAMPP PHP explicitly when PATH is uncertain:

```powershell
& 'C:\xampp\php\php.exe' composer.phar install --no-interaction --no-progress
& 'C:\xampp\php\php.exe' composer.phar validate --no-check-publish
& 'C:\xampp\php\php.exe' composer.phar audit
& 'C:\xampp\php\php.exe' composer.phar test
$env:COMPOSER_PROCESS_TIMEOUT='0'; & 'C:\xampp\php\php.exe' composer.phar check
```

## Static Route And Button Inventory

```powershell
php tools\qa-inventory.php
```

Output:

- `docs/QA_ROUTE_ACTION_INVENTORY.md`

This check is also part of `composer check`.

## XAMPP Sync

Apache serves the copy under `C:\xampp\htdocs\FieldOps-Cloud`. After code or template changes, sync the changed project files before browser checks:

```powershell
Copy-Item -Path src,templates,public,tools,tests,docs,composer.json,composer.lock -Destination 'C:\xampp\htdocs\FieldOps-Cloud' -Recurse -Force
```

## XAMPP Browser Smoke

Requires XAMPP Apache running and Chrome installed.

```powershell
$env:FIELDOPS_BASE_URL='http://localhost/FieldOps-Cloud/public'
$env:BROWSER_EXECUTABLE_PATH='C:\Program Files\Google\Chrome\Application\chrome.exe'
$env:NODE_PATH='C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules;C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules\.pnpm\node_modules'
& 'C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe' tools\browser-smoke.cjs
```

The smoke test covers public, tenant-owner, and platform-admin scenarios across mobile, tablet, and desktop viewports. It blocks service workers and serves empty test stubs for jsDelivr assets so local results are not affected by PWA cache state or CDN availability.

## XAMPP Role/RBAC Browser Walkthrough

Requires XAMPP Apache running and Chrome installed.

```powershell
$env:FIELDOPS_BASE_URL='http://localhost/FieldOps-Cloud/public'
$env:BROWSER_EXECUTABLE_PATH='C:\Program Files\Google\Chrome\Application\chrome.exe'
$env:NODE_PATH='C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules;C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules\.pnpm\node_modules'
& 'C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe' tools\role-walkthrough.cjs
```

The role walkthrough covers Owner, Manager, Supervisor, Team Member, Trainee, read-only Demo User, Platform Admin, forbidden-route 403 checks, role-filtered navigation, and platform-admin support login-as/return flow. It uses the same isolated browser context and CDN stubs as the route smoke.

## Production Auth Smoke

Runs a temporary PHP development server in production mode with demo access disabled and a disposable SQLite database seeded with DB-backed role users.

```powershell
$env:BROWSER_EXECUTABLE_PATH='C:\Program Files\Google\Chrome\Application\chrome.exe'
$env:NODE_PATH='C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules;C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules\.pnpm\node_modules'
& 'C:\Users\chama\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe' tools\auth-production-smoke.cjs
```

The production auth/security smoke verifies `/auth`, CSP/security headers, session cookie policy, disabled demo routes, unauthenticated dashboard access, invalid login, signup, DB-backed login for Owner/Manager/Supervisor/Team Member/Trainee/Platform Admin, and platform-admin isolation. It blocks service workers and serves empty jsDelivr test stubs; the platform-admin RBAC assertion uses the authenticated browser context HTTP client to validate the same session cookie without depending on browser navigation lifecycle timing.

## MySQL Health

```powershell
& 'C:\xampp\mysql\bin\mysqladmin.exe' -u root ping
& 'C:\xampp\mysql\bin\mysql.exe' --version
```

## Disposable Database Import Check

Use a throwaway database name and drop it after checking imports. Do not run this against a live tenant database.

```powershell
$db = 'fieldops_qa_' + (Get-Date -Format 'yyyyMMddHHmmss')
& 'C:\xampp\mysql\bin\mysql.exe' -u root -e "CREATE DATABASE $db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
& 'C:\xampp\mysql\bin\mysql.exe' -u root $db -e "SOURCE C:/xampp/htdocs/FieldOps-Cloud/database/schema.sql;"
& 'C:\xampp\mysql\bin\mysql.exe' -u root $db -e "SOURCE C:/xampp/htdocs/FieldOps-Cloud/database/seed.sql;"
& 'C:\xampp\mysql\bin\mysql.exe' -u root $db -e "SELECT COUNT(*) AS tables_count FROM information_schema.tables WHERE table_schema = DATABASE(); SELECT COUNT(*) AS users_count FROM users; SELECT COUNT(*) AS tenants_count FROM tenants;"
& 'C:\xampp\mysql\bin\mysql.exe' -u root -e "DROP DATABASE $db;"
```

## Current Production Readiness Evidence

The latest full QA pass is documented in:

- `docs/PRODUCTION_READINESS_QA_REPORT.md`
- `docs/QA_ROUTE_ACTION_INVENTORY.md`
