- Split single-page into 3 pages: - index.php: product catalog with VM size cards - create.php: order form (name, domain, description) - requests.php: request history with pagination - Rewrite NetBox integration to create Virtual Machines (/virtualization/virtual-machines/) instead of DCIM devices - Add netbox_integration/netbox_api.php: NetBoxClient with createVirtualMachine(), findCluster(), findTag(), getList() - Generate new sleek product-card images (420x280) with aligned spec boxes (vcpus/ram/disk) - Add webshop CSS: product cards, nav links, hero section, order layout, responsive grid - Update redirects: send.php -> requests.php, cancel.php -> requests.php - Update E2E test for new page structure - Add .gitignore, deploy-local.sh, setup_database.sql to repo
2.7 KiB
Executable File
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
./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
curl http://127.0.0.1/health.php
Returns JSON with "status": "ok" and "database": "connected" on success.
End-to-end test
./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:
- Put your NetBox API token in
.env(or setNETBOX_API_TOKENenv var) - Ensure a cluster exists in NetBox (the app looks for
proxmox-cluster) - Ensure tags exist for each domain (
domain1,domain2,domain3)
If NetBox is unreachable, the request stays as queued — no data is lost.