# Campaign Tracker A PHP MVC web application backed by Microsoft SQL Server, hosted with Docker. ## Docker Quick Start ```bash docker compose up -d --build docker compose exec campaign-tracker-app composer install docker compose exec campaign-tracker-app php scripts/migrate.php up docker compose exec campaign-tracker-app php scripts/migrate.php status ``` Open: http://localhost:8801 Health check: http://localhost:8801/health > **Note:** SQL Server takes about 10–20 seconds to be ready after `docker compose up`. If the first `migrate up` fails with a connection error, wait a moment and retry. ## Environment Copy `.env.example` to `.env` for local development outside Docker: ```bash cp .env.example .env ``` Docker injects environment variables directly from `docker-compose.yml`, so `.env` is only needed when running PHP outside a container. ## Migrations ```bash php scripts/migrate.php up # run pending migrations php scripts/migrate.php down [steps] # roll back last N migrations php scripts/migrate.php status # show migration state php scripts/migrate.php make # scaffold a new migration file php scripts/migrate.php fresh # roll back all and re-run php scripts/migrate.php fresh --seed # roll back all, re-run, seed data ``` ## Request Flow Browser → public/index.php → Request → Dispatcher → Router → Route → Controller → ViewModel/Repository → View → Response ## Main Folders - `core/` framework classes - `app/Controllers/` application controllers - `app/ViewModels/` view model classes - `app/Repositories/` data access classes - `app/Views/` PHP templates - `routes/web.php` route definitions - `database/migrations/` migrations - `scripts/` runnable PHP CLI scripts - `docker/` Docker support files ## Frontend Libraries - `Alpine.js` for lightweight page state and dynamic form interactions - `Tabulator` for the interactive data grid ## Flow chart See [`REQUEST_FLOW.md`](./REQUEST_FLOW.md) for a chart of how requests and responses move through the framework.