Codebase

Public Website web2

The public-facing Macaroni KID site — server-rendered PHP serving every town on its own subdomain.

Repository
macaroni-kid-2.web2
Language / runtime
PHP 7.4 (Apache, Debian Bullseye)
Build tooling
Gulp + Sass (node-sass)
Container
php:7.4.33-apache-bullseye; mod_rewrite enabled; serves on port 80
Production endpoint
*.macaronikid.com (per-town subdomains)
Code location on server
/var/www/html

How it works

Entry is index.php, which loads settings.php, then includes/functions.php and includes/router.php. The router resolves the town from the subdomain and dispatches to a page template in includes/ (home, articles, events, business directory, guides, contact, static pages, 404, etc.). Each template pulls its data from the REST API and renders HTML server-side.

API configuration

settings.php selects the API base by environment:

Production
API_ROOT = https://api.macaronikid.com/api/v1
Development
API_ROOT = https://api.macaronikidlab.com/api/v1

Pageview tracking

On render, pages call the API's own tracker. includes/functions.php (internalTrack()) and js/general.js hit api/v1/statistic/trackView?slug=<subdomain>&type=<device>, which records the hit into the TownViewCount collection. This — not any third-party analytics — is what feeds the pageview figures in the admin panel.

Newsletters & weather

Email templates live in email_templates/. The dynamic newsletter (dynamic-newsletter.php) calls AccuWeather's dataservice.accuweather.com to look up a town's location by ZIP and embed a 5-day forecast.

Deployment

The repo ships a Dockerfile (Apache + PHP, installs mysqli/pdo_mysql extensions) and a GitHub Actions workflow (.github/workflows/docker.yml) that builds the image. A legacy webhook deploy script, git-deploy.php, also exists — it pulls the latest code on push and is restricted to a GitHub IP allow-list (plus one developer IP).

Note on naming
This repo is web2. The older production Docker Compose file still references an earlier macaroni-kid-2.web; web2 is the current public site. See Environments & Deployment.

Key paths

PathPurpose
index.phpFront controller
settings.phpEnvironment config, API roots, CAPTCHA & API keys
includes/router.phpSubdomain → template routing
includes/functions.phpShared helpers, API calls, internalTrack()
includes/template-*.phpPage templates (home, articles, events, directory, …)
email_templates/Newsletter HTML (incl. AccuWeather forecast)
js/general.jsFront-end JS incl. pageview tracking
git-deploy.phpLegacy webhook deploy (IP-restricted)