# phpsite VM request webshop. Users browse VM configurations (Small / Medium / Big), pick one, fill in details, and submit a request. Completed requests are registered in NetBox as virtual machines. Tech stack: plain PHP, MariaDB, Nginx + PHP-FPM, optional NetBox integration. ## File layout ``` ├── index.php # Shop home — product cards for each VM size ├── create.php # Order form (pre-filled with chosen size) ├── requests.php # My Requests — history table with pagination ├── send.php # POST handler: validate, insert, call NetBox ├── cancel.php # Cancel a queued request ├── login.php # Sign-in page (database auth) ├── logout.php # Session destroy + redirect ├── config.php # Shared helpers: db(), require_login(), h(), CSRF ├── sizes.php # VM size definitions + allowed domains ├── style.css # All CSS (Inter font, dark-mode, webshop styles) ├── health.php # Health check endpoint (returns JSON) ├── setup_database.sql # MariaDB schema (users + vm_requests tables) ├── deploy-local.sh # One-shot local deployment script ├── test-e2e.sh # End-to-end smoke test ├── vm_images/ # Auto-generated product-card images ├── netbox_integration/ # NetBox API client for virtualization VMs │ ├── config.php # Load .env token, build client config │ └── netbox_api.php # NetBoxClient class (createVirtualMachine, etc.) └── .gitignore ``` ## Deploy locally ```sh ./deploy-local.sh ``` Creates the MariaDB database/user, writes `config.local.php`, imports the schema, seeds an admin user, and enables Nginx + PHP-FPM. **Default local login:** `admin` / `admin123` ## Health check ```sh curl http://127.0.0.1/health.php ``` Returns JSON with `"status": "ok"` and `"database": "connected"` on success. ## End-to-end test ```sh ./test-e2e.sh PHPSITE_URL=http://127.0.0.1:8000 ./test-e2e.sh ``` Checks PHP syntax, signs in, submits a VM request, and verifies it appears. ## NetBox integration When a request is submitted, `send.php` calls NetBox (`/virtualization/virtual-machines/`) to create a virtual machine entry. The VM is tagged with the chosen domain and attached to the first available cluster. To enable: 1. Put your NetBox API token in `.env` (or set `NETBOX_API_TOKEN` env var) 2. Ensure a cluster exists in NetBox (the app looks for `proxmox-cluster`) 3. Ensure tags exist for each domain (`domain1`, `domain2`, `domain3`) If NetBox is unreachable, the request stays as `queued` — no data is lost.