# CakePHP Docker Stack Two containers: - **composer** — PHP CLI + Composer (with the `intl`, `zip`, `mbstring` extensions CakePHP needs). Used on demand to scaffold/manage the app; it isn't a long-running service. - **web** — Apache + PHP (`intl`, `pdo_mysql`, `mbstring`, `zip`, `gd`, `mod_rewrite`) serving `./app/webroot`. - **db** — MySQL 8.4, database `cakephp`, user `cakephp` / password `cakephp` (root password `root`). Data persists in the `db_data` named volume. Port 3306 is published to the host if you want to connect with a GUI client (Workbench, TablePlus, etc.). `composer` and `web` share the `./app` directory as the CakePHP application root. `app/config/app_local.php` is already pointed at the `db` service (host `db`, database/user/password `cakephp`). ## First-time setup The app was scaffolded with: ```bash docker compose build docker compose run --rm --entrypoint sh composer -c \ "composer create-project --prefer-dist cakephp/app /tmp/app --no-interaction && cp -a /tmp/app/. /var/www/html/" ``` (Scaffolding via `/tmp` inside the container and copying out avoids a Composer bug deleting temp files directly on a Windows bind mount.) ## Usage Start the site: ```bash docker compose up -d web ``` Visit http://localhost:8080 Run Composer commands against the app (e.g. installing a plugin): ```bash docker compose run --rm composer require cakephp/authentication ``` Run `bin/cake` console commands via the web container: ```bash docker compose exec web php bin/cake.php bake controller Articles ``` ## Database Bring the DB up alongside the app: ```bash docker compose up -d db web ``` Run migrations/bake against it once you have tables: ```bash docker compose exec web php bin/cake.php migrations migrate ``` Connect from a host GUI client at `127.0.0.1:3306` using `cakephp` / `cakephp` (or `root` / `root`). ## Geo (dereuromark/cakephp-geo) The `Geo` plugin is installed and loaded (`app/src/Application.php`). Setup: - **Geocoding** (address <-> lat/lng) uses the Google Maps provider, configured in `app/config/app.php` under `Geocoder`. - **Map tiles** (`LeafletHelper`) are served by MapTiler, configured under `Leaflet.tileLayer`. Both need API keys, passed into the `web` container as environment variables: ```bash cp .env.example .env # edit .env and set GOOGLE_MAPS_API_KEY and MAPTILER_API_KEY docker compose up -d web ``` - Google Maps API key (Geocoding API enabled): https://console.cloud.google.com/google/maps-apis/credentials - MapTiler API key: https://cloud.maptiler.com/account/keys/ Without keys, geocoding calls and map tiles will fail/return blank tiles, but the rest of the app is unaffected.