You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add configurable console styles for CLI output, including severity backgrounds, syntax highlighting, and semantic tags. Refactor ConsoleStyler and CodeHighlighter to support overrides via config or environment variable. Update documentation with usage examples.
- PHP_ERROR_INSIGHT_ROOT: absolute project root to compute relative file paths in the stack (optional)
39
39
- PHP_ERROR_INSIGHT_HOST_ROOT: absolute host project root used to map container paths when opening files via editor links (optional; useful in Docker)
40
40
- PHP_ERROR_INSIGHT_EDITOR: editor URL template for clickable file links, using %file and %line placeholders (e.g. "vscode://file/%file:%line" or "phpstorm://open?file=%file&line=%line")
For more details, see docs/sanitizzazione-dati-ai.md.
183
184
185
+
## Console colors customization (CLI)
186
+
187
+
You can customize the colors used in the CLI output (syntax highlighting, severity header background, title, AI suggestions, stack trace and locations).
188
+
189
+
Two ways to configure:
190
+
191
+
- Environment variable `PHP_ERROR_INSIGHT_CONSOLE_COLORS` containing a JSON object
192
+
- Programmatic via `Config::fromEnvAndArray(['consoleColors' => [...]])`
193
+
194
+
Structure of the JSON/object:
195
+
196
+
```json
197
+
{
198
+
"tokens": {
199
+
"default": ["white", null, []],
200
+
"comment": ["white", null, []],
201
+
"string": ["yellow", null, []],
202
+
"keyword": ["magenta", null, ["bold"]],
203
+
"html": ["cyan", null, ["bold"]],
204
+
"variable": ["cyan", null, []],
205
+
"function": ["blue", null, ["bold"]],
206
+
"method": ["green", null, ["underscore"]]
207
+
},
208
+
"severity": {
209
+
"error": "red",
210
+
"warning": "yellow",
211
+
"info": "blue"
212
+
},
213
+
"styles": {
214
+
"title": ["white", null, ["bold"]],
215
+
"suggestion": ["green", null, []],
216
+
"stack": ["yellow", null, []],
217
+
"location": ["blue", null, []],
218
+
"gutter_hl": ["white", "red", ["bold"]],
219
+
"gutter_num": ["gray", null, []],
220
+
"gutter_sep": ["gray", null, []]
221
+
}
222
+
}
223
+
```
224
+
225
+
Notes:
226
+
- Each style uses the form `[fg, bg, options[]]`. `fg` and `bg` accept Symfony Console color names (e.g., "white", "yellow", "red", "blue", "cyan", "magenta", "gray"), and `options` can include `bold`, `underscore`, `blink`, `reverse`, `conceal`.
227
+
-`tokens` overrides the syntax highlighter palette for these categories: `default`, `comment`, `string`, `keyword`, `html`, `variable`, `function`, `method`.
228
+
-`severity` maps `error|warning|info` to a background color name for the header badge with the severity label.
229
+
-`styles` lets you tweak semantic tags used by the renderer: `title` (error message), `suggestion` (AI suggestions label and items), `stack` (stack trace lines when rendered in compact mode), `location` (file:line), `gutter_hl` (current line number in code excerpts), `gutter_num` (non-current line numbers), and `gutter_sep` (the vertical separator).
230
+
- Any key you omit falls back to sensible defaults.
0 commit comments