|
| 1 | +# shimkit framework symfony |
| 2 | + |
| 3 | +Symfony-specific helpers. Four commands today. Modelled on the |
| 4 | +Laravel recipe — same parent sub-app, same builder pattern, same |
| 5 | +host-or-container console passthrough — adjusted for Symfony's |
| 6 | +conventions: writable `var/` (not `storage/`), `APP_SECRET` hex |
| 7 | +(not `APP_KEY` base64), `bin/console` (not root `artisan`). |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +| Command | Purpose | |
| 12 | +|---------|---------| |
| 13 | +| `shimkit framework symfony` | Menu. | |
| 14 | +| `shimkit framework symfony perms PATH [--group G]` | MODERATE. Fix `var/` permissions. | |
| 15 | +| `shimkit framework symfony env PATH [--name N] [--env E] [--db D]` | MODERATE. Scaffold `.env.local` with a generated `APP_SECRET`. | |
| 16 | +| `shimkit framework symfony cache-clear PATH [--env E]` | Wraps `php bin/console cache:clear --env <env>`. | |
| 17 | +| `shimkit framework symfony console -- <args>` | Passthrough to `bin/console` — host or LEMP container. | |
| 18 | + |
| 19 | +Universal flags before the subcommand (`--quiet`, `--verbose`, |
| 20 | +`--log-file`, `--no-color`, `--color`, `--no-input`); per-command |
| 21 | +flags after (`--json`, `--dry-run`, `--yes`, `--force`). |
| 22 | + |
| 23 | +## perms |
| 24 | + |
| 25 | +`var/` is the standard Symfony writable tree (covers `cache/`, |
| 26 | +`log/`, `sessions/`). Set `tools.framework.symfony.writable_dirs` |
| 27 | +in your user config to extend (e.g. `["var", "public/uploads"]`). |
| 28 | + |
| 29 | +```bash |
| 30 | +# Default www-data group on Linux |
| 31 | +shimkit framework symfony perms --yes ./my-symfony-app |
| 32 | + |
| 33 | +# macOS-friendly group |
| 34 | +shimkit framework symfony perms --yes --group staff ./my-symfony-app |
| 35 | + |
| 36 | +# Dry-run plan |
| 37 | +shimkit framework symfony perms --dry-run ./my-symfony-app |
| 38 | + |
| 39 | +# JSON (CI / monitoring) |
| 40 | +shimkit framework symfony perms --yes --json ./my-symfony-app |
| 41 | +``` |
| 42 | + |
| 43 | +Group detection: `getent group <name>` on Linux, `dscl . -read |
| 44 | +/Groups/<name>` on macOS, `grp.getgrnam()` Python fallback. When |
| 45 | +the group doesn't exist on the host, the global `chmod 664` / |
| 46 | +`chmod 775` passes still run but `chgrp` is skipped (UI.dim |
| 47 | +explains). |
| 48 | + |
| 49 | +## env |
| 50 | + |
| 51 | +Writes `.env.local` with a freshly generated `APP_SECRET`. Symfony's |
| 52 | +convention is that **`.env` (checked in) holds framework defaults** |
| 53 | +and **`.env.local` (gitignored) holds secrets + per-host tweaks**. |
| 54 | +shimkit writes to `.env.local` so the framework-provided `.env` |
| 55 | +stays intact. |
| 56 | + |
| 57 | +`APP_SECRET` is `secrets.token_hex(32)` = 64 hex chars — the |
| 58 | +[Symfony reference](https://symfony.com/doc/current/reference/configuration/framework.html#secret) |
| 59 | +recommends a long random hex. |
| 60 | + |
| 61 | +`DATABASE_URL` defaults target the shimkit dev DBs: |
| 62 | + |
| 63 | +| `--db` | URL prefix | Port | `?serverVersion=` | |
| 64 | +|------------|------------|-----:|-------------------| |
| 65 | +| `mysql` | `mysql://` | 13306 | `8.0` | |
| 66 | +| `mariadb` | `mysql://` | 13307 | `mariadb-10.11` | |
| 67 | +| `postgres` | `postgresql://`| 15432 | `16` | |
| 68 | + |
| 69 | +```bash |
| 70 | +shimkit db postgres up |
| 71 | +shimkit framework symfony env --yes --db postgres ./my-app |
| 72 | +shimkit framework symfony console --project ./my-app -- doctrine:migrations:migrate |
| 73 | +``` |
| 74 | + |
| 75 | +## cache-clear |
| 76 | + |
| 77 | +Wraps `php bin/console cache:clear --env <env>`: |
| 78 | + |
| 79 | +```bash |
| 80 | +shimkit framework symfony cache-clear --env dev ./my-app |
| 81 | +shimkit framework symfony cache-clear --env prod --in-container --stack myapp ./my-app |
| 82 | +``` |
| 83 | + |
| 84 | +Default env is `dev` (configurable via |
| 85 | +`tools.framework.symfony.default_env`). |
| 86 | + |
| 87 | +## console |
| 88 | + |
| 89 | +Generic passthrough to `bin/console`. Host execution is the |
| 90 | +default — preflights `php` via `shimkit.core.version.preflight`, |
| 91 | +exits 69 with the remediation hint when `php` is missing. |
| 92 | +`--in-container` routes through `shimkit stack lemp`'s php-fpm |
| 93 | +container. |
| 94 | + |
| 95 | +```bash |
| 96 | +# Host |
| 97 | +shimkit framework symfony console --project ./my-app -- about |
| 98 | +shimkit framework symfony console --project ./my-app -- doctrine:database:create |
| 99 | + |
| 100 | +# Inside a running LEMP stack |
| 101 | +shimkit stack lemp up --project myapp ./my-app |
| 102 | +shimkit framework symfony console \ |
| 103 | + --project ./my-app --in-container --stack myapp \ |
| 104 | + -- doctrine:migrations:migrate |
| 105 | +``` |
| 106 | + |
| 107 | +`--project` defaults to the current working directory. |
| 108 | + |
| 109 | +## No cron-install |
| 110 | + |
| 111 | +Symfony doesn't ship a built-in scheduler analogous to Laravel's |
| 112 | +`schedule:run`. Application-specific cron entries can be installed |
| 113 | +via `shimkit cron add` directly: |
| 114 | + |
| 115 | +```bash |
| 116 | +shimkit cron add --yes \ |
| 117 | + --name my-symfony-nightly \ |
| 118 | + --schedule "0 3 * * *" \ |
| 119 | + --cmd "cd /var/www/my-app && php bin/console app:nightly-job >> /dev/null 2>&1" |
| 120 | +``` |
| 121 | + |
| 122 | +If Symfony Scheduler (the messenger-based approach) gains broad |
| 123 | +adoption, a `cron-install` command may land later. |
| 124 | + |
| 125 | +## Configuration |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "tools": { |
| 130 | + "framework": { |
| 131 | + "symfony": { |
| 132 | + "web_group": "www-data", |
| 133 | + "file_mode": "664", |
| 134 | + "dir_mode": "775", |
| 135 | + "writable_dirs": ["var"], |
| 136 | + "default_env": "dev" |
| 137 | + } |
| 138 | + } |
| 139 | + } |
| 140 | +} |
| 141 | +``` |
| 142 | + |
| 143 | +Override `web_group` per host. Add `writable_dirs` entries if your |
| 144 | +app writes outside `var/` (e.g. `public/uploads/`). |
| 145 | + |
| 146 | +## Exit codes |
| 147 | + |
| 148 | +| Code | Meaning | |
| 149 | +|-----:|---------| |
| 150 | +| 0 | success | |
| 151 | +| 1 | bad path, missing `bin/console`, refusing overwrite, prompt cancelled | |
| 152 | +| 2 | Typer usage error | |
| 153 | +| 69 | `EX_UNAVAILABLE` — wrong platform or missing `php` for `console`/`cache-clear` | |
| 154 | +| 130 | SIGINT | |
| 155 | + |
| 156 | +## Platform support |
| 157 | + |
| 158 | +| Platform | Status | |
| 159 | +|----------|--------| |
| 160 | +| macOS | full. Dev account typically owns the project, so `chgrp` is no-op'd unless `--group` is passed. | |
| 161 | +| Linux | full. Targets `www-data` by default; override with `--group`. | |
| 162 | +| WSL | works (Linux path). | |
| 163 | +| Windows | out of charter (use WSL). | |
0 commit comments