VOOZH about

URL: https://deepwiki.com/invokable/laravel-boost-phpstorm-copilot/8.1-phpstormcopilot-class-api

⇱ PhpStormCopilot Class API | invokable/laravel-boost-phpstorm-copilot | DeepWiki


Loading...
Last indexed: 28 February 2026 (57ef88)
Menu

PhpStormCopilot Class API

This page is a method-by-method reference for the PhpStormCopilot class defined in src/PhpStormCopilot.php It covers every public and protected method: its signature, parameter types, return type, and precise behavioral description.

For the conceptual role this class plays in the installation pipeline, see 4.1. For the WSL-specific methods provided by the WithWSL trait this class uses, see 8.2. For the service provider that registers this class with the framework, see 8.3.


Class Overview

File: src/PhpStormCopilot.php

Namespace: Revolution\Laravel\Boost

PhpStormCopilot is the central agent implementation in this package. It extends the abstract Agent base class from laravel/boost and implements three contracts: SupportsGuidelines, SupportsMcp, and SupportsSkills. It also uses the WithWSL trait from Revolution\Laravel\Boost\Concerns\WithWSL.

Inheritance and contracts diagram:


Sources: src/PhpStormCopilot.php1-18


Method Reference

name()

src/PhpStormCopilot.php19-22

Visibilitypublic
Parametersnone
Returnsstring

Returns the machine-readable identifier for this agent. Used by Boost::registerAgent and internally by Boost to key configuration and registration.

Return value: 'phpstorm-copilot'


displayName()

src/PhpStormCopilot.php24-27

Visibilitypublic
Parametersnone
Returnsstring

Returns the human-readable label shown to developers during boost:install agent selection.

Return value: 'PhpStorm with GitHub Copilot'


useAbsolutePathForMcp()

src/PhpStormCopilot.php29-32

Visibilitypublic
Parametersnone
Returnsbool

Signals to the parent Agent that the PHP binary and artisan paths written into mcp.json must be absolute. PhpStorm's GitHub Copilot plugin spawns the MCP subprocess from a system-level config file, so relative paths would not resolve correctly.

Return value: true (always)


systemDetectionConfig(Platform $platform)

src/PhpStormCopilot.php34-67

Visibilitypublic
ParametersPlatform $platform — a Laravel\Boost\Install\Enums\Platform enum case
Returnsarray{paths?: string[], command?: string, files?: string[]}

Returns platform-specific filesystem paths used by the boost:install detection strategy to determine whether PhpStorm (with the GitHub Copilot plugin) is present on the developer's system.

Per-platform paths:

Platform casePaths checked
Platform::Darwin~/Library/Application Support/JetBrains/PhpStorm*/plugins/github-copilot-intellij, /Applications/PhpStorm.app
Platform::Linux/opt/phpstorm, /opt/PhpStorm*, /usr/local/bin/phpstorm, ~/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-*, /mnt/c/Users/*/AppData/Local/github-copilot (WSL)
Platform::Windows%LOCALAPPDATA%\github-copilot\intellij, %ProgramFiles%\JetBrains\PhpStorm*, %LOCALAPPDATA%\JetBrains\Toolbox\apps\PhpStorm\ch-*, %LOCALAPPDATA%\Programs\PhpStorm

The Linux case includes a WSL path (/mnt/c/...) so that PhpStorm running on the Windows host is still detected when the project runs inside WSL.

For a detailed explanation of detection strategy behavior, see 4.2.

Sources: src/PhpStormCopilot.php39-67


projectDetectionConfig()

src/PhpStormCopilot.php69-79

Visibilitypublic
Parametersnone
Returnsarray{paths?: string[], files?: string[]}

Returns project-level indicators that suggest this agent is already configured in the current Laravel project. The detection checks for the presence of .github/copilot-instructions.md — a standard GitHub Copilot configuration file that would exist if the project was previously set up.

Return value:


Sources: src/PhpStormCopilot.php74-79


guidelinesPath()

src/PhpStormCopilot.php81-89

Visibilitypublic
Parametersnone
Returnsstring
ImplementsSupportsGuidelines

Returns the path (relative to the Laravel project root) where the AI guideline file should be written during boost:install. The path is configurable via config('boost.agents.phpstorm_copilot.guidelines_path').

Default return value: '.github/instructions/laravel-boost.instructions.md'

This file instructs GitHub Copilot inside PhpStorm about project conventions and available tools. See 3.3 for the purpose and format of this file.

Sources: src/PhpStormCopilot.php86-89


skillsPath()

src/PhpStormCopilot.php91-97

Visibilitypublic
Parametersnone
Returnsstring
ImplementsSupportsSkills

Returns the directory path (relative to the Laravel project root) where agent skill files should be written during boost:install. Configurable via config('boost.agents.phpstorm_copilot.skills_path').

Default return value: '.github/skills'

Sources: src/PhpStormCopilot.php94-97


mcpConfigKey()

src/PhpStormCopilot.php99-102

Visibilitypublic
Parametersnone
Returnsstring
ImplementsSupportsMcp

Returns the top-level JSON key used in mcp.json under which individual MCP server entries are nested. PhpStorm's GitHub Copilot plugin expects server entries under "servers".

Return value: 'servers'

Example mcp.json structure this key governs:


Sources: src/PhpStormCopilot.php99-102


mcpConfigPath()

src/PhpStormCopilot.php104-114

Visibilitypublic
Parametersnone
Returnsstring
ImplementsSupportsMcp

Returns the absolute filesystem path to mcp.json for the current platform. Uses Platform::current() to detect the OS at runtime, and reads HOME from the environment for Unix-like systems.

PlatformReturned path
Platform::Darwin{HOME}/.config/github-copilot/intellij/mcp.json
Platform::Linux{HOME}/.config/github-copilot/intellij/mcp.json
Platform::Windows%LOCALAPPDATA%\github-copilot\intellij\mcp.json

Note: In WSL environments, installFileMcp intercepts execution before mcpConfigPath() is used for writing, delegating instead to installMcpViaWsl(). See 5.3 for WSL details.

Sources: src/PhpStormCopilot.php104-114


installFileMcp(string $key, string $command, array $args = [], array $env = [])

src/PhpStormCopilot.php116-132

Visibilityprotected
Parametersstring $key — entry name in mcp.json; string $command — the executable; array $args — CLI arguments; array $env — environment variables
Returnsbool
ThrowsException if running inside Testbench
OverridesAgent::installFileMcp

This is the primary dispatch method for writing the MCP configuration. It applies environment-specific branching before delegating to the parent class.

Decision flow:


Behavior summary:

  1. Testbench guard — If TESTBENCH_CORE is defined, throws an Exception. This prevents the boost:install command from writing system-level config during test runs.
  2. WSL branch — If WSL_DISTRO_NAME is set in the environment, delegates entirely to installMcpViaWsl() from the WithWSL trait. The WSL path writes to the Windows-side mcp.json via PowerShell.
  3. Standard branch — Passes command and args through transformSailCommand() to handle Sail environments, then calls parent::installFileMcp() which writes the config to disk at mcpConfigPath().

For the complete WSL pipeline, see 5.3. For Sail handling, see 5.4.

Sources: src/PhpStormCopilot.php119-132


transformSailCommand(string $command, array $args)

src/PhpStormCopilot.php134-162

Visibilitypublic
Parametersstring $command — the base command (e.g., ./vendor/bin/sail or an absolute PHP path); array $args — the arguments (e.g., ['artisan', 'boost:mcp'])
Returnsarray{command: string, args: array}

Detects whether the command is a Sail invocation and, if so, wraps it in a bash -c 'cd {projectPath} && ./vendor/bin/sail {args}' shell invocation. This ensures PhpStorm's MCP subprocess runs Sail from the correct working directory.

Decision logic:


Examples:

Input commandInput argsOutput commandOutput args
/usr/bin/php['/path/artisan', 'boost:mcp']/usr/bin/php['/path/artisan', 'boost:mcp']
./vendor/bin/sail['artisan', 'boost:mcp']bash['-c', "cd /path/to/project && ./vendor/bin/sail 'artisan' 'boost:mcp'"]
/home/user/project/vendor/bin/sail['artisan', 'boost:mcp']bash['-c', "cd /path/to/project && ./vendor/bin/sail 'artisan' 'boost:mcp'"]

The condition checked is $command !== './vendor/bin/sail' && !str_ends_with($command, '/vendor/bin/sail'), so both relative and absolute paths to the Sail binary are caught src/PhpStormCopilot.php144

Sources: src/PhpStormCopilot.php141-162


removeEmptyArrays(array $data)

src/PhpStormCopilot.php163-181

Visibilityprotected
Parametersarray $data — the config array to clean
Returnsarray

Recursively removes any array values that are empty ([]) from a nested config array. This prevents compatibility issues with MCP clients that fail on empty arrays (such as "headers": [] in a config entry). Called by installMcpViaWsl() in the WithWSL trait before serializing the config to JSON.

The method walks the array depth-first: if a value is an array and empty, the key is unset; if it is a non-empty array, removeEmptyArrays is called recursively on it; scalar values are left unchanged src/PhpStormCopilot.php168-180

Sources: src/PhpStormCopilot.php164-181 src/Concerns/WithWSL.php48


isRunningInTestbench()

src/PhpStormCopilot.php183-186

Visibilityprotected
Parametersnone
Returnsbool

Detects whether the code is currently executing inside an Orchestra Testbench environment by checking for the TESTBENCH_CORE constant. Used exclusively as a guard inside installFileMcp() to abort execution before any filesystem or process side effects occur.

Return value: defined('TESTBENCH_CORE')

This is a protected method rather than a public one — tests that need to verify its behavior do so indirectly by observing that installFileMcp() throws an exception.

Sources: src/PhpStormCopilot.php183-186


Method Visibility Summary


Sources: src/PhpStormCopilot.php1-187 src/Concerns/WithWSL.php1-129


Contract Implementation Map

Interface / BaseMethodDefined In
Agent (abstract)installFileMcpPhpStormCopilot (overrides)
Agent (abstract)name, displayName, useAbsolutePathForMcp, systemDetectionConfig, projectDetectionConfigPhpStormCopilot
SupportsGuidelinesguidelinesPathPhpStormCopilot
SupportsMcpmcpConfigKey, mcpConfigPathPhpStormCopilot
SupportsSkillsskillsPathPhpStormCopilot
WithWSL (trait)isWSL, installMcpViaWsl, transformMcpCommandForWslConcerns/WithWSL.php
PhpStormCopilot (own)transformSailCommand, removeEmptyArrays, isRunningInTestbenchPhpStormCopilot

Sources: src/PhpStormCopilot.php15-17 src/Concerns/WithWSL.php9