PhpStorm MCP Workflows
Use this skill when PhpStorm MCP should be the source of truth for PHP project context, code structure, inspections, search, refactoring, and validation on PHP work.
Reality Check
- Prefer the tools actually exposed in the current session over any memorized inventory.
- Tool exposure varies by IDE version, enabled plugins, and allow-list settings such as
idea_mcp_allowed_tools. - Start from project context on non-trivial PHP tasks.
- For PHP code, start with the richest PhpStorm answer available: framework-aware tools, semantic navigation, inspections, structural search, or IDE actions before low-level reads or text search.
- When semantics are exhausted and low-level access is still needed, prefer PhpStorm MCP readers and searchers over shell commands or raw filesystem tooling when the cost is comparable.
- Keep the base workflow framework-agnostic and capability-light. Load overlays only when the task or project proves they are needed.
Core Defaults
- Bootstrap PHP project context first. For repeated field work, prefer
scripts/phpstorm-project-bootstrap.phpto runget_php_project_config,get_composer_dependencies,get_project_modules,get_repositories, andget_run_configurationsin one MCP session. - For PHP code, ask the strongest question first: framework-aware tools,
get_inspections,search_symbol,get_symbol_info, orsearch_structuralbeforeread_file,search_text, or regex. - Prefer semantic tools over text tools for code:
search_symbol->get_symbol_info->read_file. - Prefer lower-level PhpStorm MCP tools such as
read_file,search_file,search_text, andsearch_regexover external shell or filesystem tools when both can solve the task with similar effort. - For bounded textual edits after semantic narrowing, prefer
apply_patchfor multi-hunk local changes andreplace_text_in_filefor exact literal substitutions. - Prefer
get_inspectionsover ad-hoc guessing. - Use
apply_quick_fixonly after selecting an exact quick fix fromget_inspections. - Prefer
rename_refactoringoverreplace_text_in_fileorapply_patchfor identifiers. - Prefer
search_structuralover regex when the target is a PHP code shape. - Treat external CLI search or read tooling as fallback only when PhpStorm MCP lacks the capability or is materially less effective.
- For high-volume batches, use MCP for bootstrap, representative sampling, inspections, and disputed cases rather than every identical occurrence.
- Keep MCP endpoint settings in
config/mcp.php; create or overwrite it withscripts/configure-mcp.sh <mcp-url>and do not hard-code the PhpStorm stream URL in scripts. - When a repeated MCP sequence costs multiple agent cycles, add a PHP 7.4-compatible script under
scripts/and use it for the current batch. - If any helper script exits with an error, stop that execution path immediately, surface the script error, and give concrete remediation steps before continuing.
- Inspect representative hits before bulk edits, even when the pattern looks obvious.
- After semantic refactors, audit strings, templates, route names, service IDs, config keys, and docs with
search_text. - For behavior changes, do not stop at
build_project; runexecute_run_configurationor the nearest project test path. - Use
search_ide_actionsandinvoke_ide_actiononly when no dedicated MCP tool exists and the action context is likely to complete safely. - If a tool named here is unavailable, choose the next smallest safe tool and state the fallback explicitly.
Core Workflows
Bootstrap a PHP project
- Prefer
scripts/phpstorm-project-bootstrap.php --project-path <path>for field work. - Otherwise call
get_php_project_config get_composer_dependenciesget_project_modulesandget_repositoriesget_run_configurations- If needed,
list_directory_treeorsearch_filefor entrypoints and config files - If Composer packages or layout identify a framework, load the matching file under
references/frameworks/
Investigate a symbol or code path
search_symbolget_symbol_inforead_filearound the narrowed declaration and key usages- Use
search_textonly for non-code references
Investigate a type or data-flow question
get_symbol_infoget_inspectionsif a diagnostic is involvedsearch_ide_actionsforExpressionTypeInfo,SliceBackward, orSliceForwardif no dedicated MCP tool answers the question directlyinvoke_ide_actiononly when the session already has a reliable editor and caret target at the expression; otherwise treat these IDE actions as manual-only fallbackread_fileorsearch_structuralonly after the semantic or IDE-assisted step has narrowed the target
Fix an inspection-driven issue
get_inspections- If a precise quick fix exists,
apply_quick_fix - Re-run
get_inspections build_projecton touched files when the change is meaningful- Run behavior validation if the fix can affect runtime behavior
Safe rename or bounded refactor
- Inspect the declaration and likely usages with semantic tools
rename_refactoringfor identifiers, orsearch_ide_actionsbefore a dialog-driven refactor- Re-run
get_inspections build_projectsearch_textfor non-code references the semantic change may not cover- Run behavior validation if a public API, framework entrypoint, or call pattern changed
Syntax-aware cleanup or migration
search_structuralor, if absent,search_regex- Inspect representative hits with
read_file - Make the smallest safe edit: quick fix,
apply_patch, targeted replace, or refactor - Re-run inspections and build
- Escalate to reusable inspection tooling only when repetition is high
High-volume field automation
- Create or overwrite MCP connection settings with
scripts/configure-mcp.sh <mcp-url>. - Store only concrete local settings in
config/mcp.php; keepconfig/mcp.php.distas a placeholder template. - Use
scripts/mcp-tool.phpfor one-off direct tool calls from shell scripts. - Use
scripts/phpstorm-project-bootstrap.phpfor project bootstrap in one request cycle. - Use
scripts/phpstorm-batch-inspections.phpto runget_inspectionsover a known file list in one MCP session. - If a repeated MCP sequence is missing, add a small PHP 7.4-compatible script in
scripts/instead of repeating manual tool calls. - Keep scripts dry-run/reporting by default when they can mutate files or influence a batch decision.
Script failure handling
- Treat any non-zero exit from
scripts/helpers as a hard stop for that workflow branch. - Report the original stderr or exception text instead of masking it with a fallback action.
- Give the smallest corrective action that can unblock the user, then resume only after that prerequisite is satisfied.
- If
config/mcp.phpis missing or contains unresolved placeholders, tell the user to runscripts/configure-mcp.sh <mcp-url>before retrying.
Escalation Paths
Load additional references only when the task calls for them.
- Framework-specific discovery:
references/frameworks/ - Database-assisted tasks:
references/capabilities/database.md - Runtime-only debugging:
references/capabilities/debugging.md - Large migration or repeated structural fixes:
references/capabilities/custom-inspections.md - Detailed tool-choice tables and refactoring fallbacks:
references/playbook.md - Version and documentation gap notes:
references/toolset-2026-1.md
Validation Ladder
Use the narrowest validation that can still catch the likely failure mode.
- Static-only edit:
get_inspections - Single-file semantic edit:
get_inspections->build_project - Cross-file rename or refactor:
get_inspectionson touched files ->build_projecton touched files ->search_textaudit - Behavior change:
get_inspections->build_project->execute_run_configurationor project test command
Guardrails
- Never use
replace_text_in_fileorapply_patchto rename an identifier ifrename_refactoringcan do it. - Never start PHP code investigation with text search, regex, or file reads if a semantic or framework-aware PhpStorm path can answer it first.
- Never bypass equivalent PhpStorm MCP readers or searchers with external shell tooling unless the IDE path is unavailable or materially less effective.
- Never treat
build_projectas enough validation for behavior changes. - Never assume semantic refactoring covers strings, comments, templates, or config text.
- Never default to regex for a symbol or syntax-shaped problem.
- Never run mutating SQL through MCP unless the user intent and the target connection are both safe.
- Do not assume
invoke_ide_actioncan drive modal dialogs end-to-end. - Do not load framework or capability overlays speculatively.
- Reformat only after logic is stable.
- Prefer actual exposed tools over stale documentation snapshots.