Generates a single data.json from FossBilling, then serves a fully static frontend.
- Generator:
gen.php - Frontend:
index.html,style.css,script.js - Output:
data.json
- PHP 8+ CLI
- PHP cURL extension
- FossBilling API key with access to required
guest/*andadmin/*endpoints used bygen.php
- Copy env template:
cp .env.example .env- Set required values in
.env:
BILLING_BASE_URL=https://billing.example.com
BILLING_API_KEY=your_api_key
PUBLIC_SITE_URL=https://example.com- Harden local file permissions (recommended):
chmod 600 .env gen.phpKeep .env and gen.php outside any web-served directory.
- Generate data:
php gen.php- Serve the static files (
index.html,style.css,script.js,data.json) from your web server.
Generate to a custom path:
php gen.php --out=./public/data.jsonOverride API connection from CLI:
php gen.php --base-url=https://billing.example.com --api-key=xxx --public-url=https://example.comUseful flags:
--pretty=0|1--show-errors=0|1--timeout=SECONDS--max-pages=N--per-page=N--strict-tls=0|1--exclude-patterns=csv,list
gen.phpfetches products, categories, addons, currencies, domains, gateways, and branding/theme data.- It normalizes and filters data for public frontend use.
- It writes
data.json. script.jsfetches/data.jsonand renders the page dynamically.
Regenerate data.json whenever catalog/pricing changes (or via cron), then keep serving the same static assets.
Example cron (every 5 minutes):
*/5 * * * * /usr/local/bin/php /home/mehrnet/public_html/gen.php --out=/home/mehrnet/public_html/data.jsonIf your host defaults php to CGI/FastCGI in cron, use an explicit CLI binary path (for example /usr/bin/php or /usr/local/bin/php-cli).