# Local Setup This guide helps you run Cleanprompt locally for development and evaluation. ## Project Links - Website: [https://nitty-witty.com/cleanprompt](https://nitty-witty.com/cleanprompt) - GitHub: [https://github.com/kedarvj/cleanprompt](https://github.com/kedarvj/cleanprompt) ## Prerequisites - PHP 8.0+ (PHP 7.4 may work, but 8.x is recommended) - A modern browser (Chrome, Edge, Firefox, Safari) - Permission to write into `data/` for stats persistence ## 1) Clone and enter project ```bash git clone cd cleanprompt ``` If you already have the code, just `cd` into the repo root. ## 2) Verify PHP ```bash php -v ``` If this command fails, install PHP and retry. ## 3) Start local server ```bash php -S localhost:8080 ``` Then open: - `http://localhost:8080` ## 4) Confirm app behavior Quick sanity checks: - UI loads with Input/Obfuscated Output panes. - Clicking **Obfuscate** updates output and diff. - **View stats** opens chart dialog. - `api/stats.php` returns JSON in browser. Optional direct API check: - Open `http://localhost:8080/api/stats.php` - You should see JSON counters. ## 5) Port alternatives If port `8080` is in use: ```bash php -S localhost:8081 ``` Then open `http://localhost:8081`. ## 6) File permissions for stats Global stats are written to `data/stats.json` by `api/stats.php`. If stats fail to persist: - Ensure the `data/` directory exists. - Ensure your local PHP process can write to `data/stats.json`. - Restart the PHP server after fixing permissions. ## 7) `http://` vs `file://` - Recommended: `http://localhost` (full behavior, including shared stats API). - `file://` may load UI but cannot use PHP API endpoints, so shared stats are unavailable. ## Common issues - **`php: command not found`**: install PHP and re-open terminal. - **Blank/404 route**: confirm server started in repo root. - **Clipboard copy fails**: browser permissions/security settings may block clipboard API. - **No global stats**: ensure `api/stats.php` is reachable and writable.