VOOZH about

URL: https://deepwiki.com/invokable/laravel-boost-phpstorm-copilot/4.2-platform-and-environment-detection

⇱ Platform and Environment Detection | invokable/laravel-boost-phpstorm-copilot | DeepWiki


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

Platform and Environment Detection

This page documents the two detection methods — systemDetectionConfig and projectDetectionConfig — defined in PhpStormCopilot, and the WSL environment check provided by the WithWSL trait. Together, these methods tell the Laravel Boost framework where to look for an existing PhpStorm installation and how to determine whether a project is configured for GitHub Copilot.

For the installation logic that uses these detected values (writing mcp.json to the correct location), see MCP Configuration Generation. For the platform-specific write paths and how each OS variant handles file output, see Platform-Specific Implementations.


Purpose of Detection

The laravel/boost framework calls detection methods to decide:

  1. System detection — Is PhpStorm with GitHub Copilot installed on this machine?
  2. Project detection — Is this project already configured to use GitHub Copilot?
  3. Environment detection — Is this PHP process running inside WSL?

These three checks drive which installation branches execute and which file paths are written.

Sources: src/PhpStormCopilot.php39-79 src/Concerns/WithWSL.php11-14


System Detection — systemDetectionConfig(Platform $platform)

systemDetectionConfig returns an array keyed by the paths key for a given Platform enum value. The laravel/boost framework passes the current platform into this method and uses the returned paths to detect whether PhpStorm is present on the host machine.

The method signature is:

public function systemDetectionConfig(Platform $platform): array

The return type is array{paths?: string[], command?: string, files?: string[]}.

Detection paths by platform:

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

Note on the Linux entry /mnt/c/Users/*/AppData/Local/github-copilot: When PHP runs inside WSL, the Windows C: drive is mounted at /mnt/c. This path allows the Linux detection branch to find GitHub Copilot installed on the Windows host, even when PhpStorm itself is running on Windows.

Sources: src/PhpStormCopilot.php39-67 tests/Feature/PhpStormCopilotTest.php29-47


Diagram: systemDetectionConfig — Platform enum values to file system paths


Sources: src/PhpStormCopilot.php39-67


Project Detection — projectDetectionConfig()

projectDetectionConfig checks for the presence of files in the project directory to determine whether the project is already configured for GitHub Copilot. Its return type is array{paths?: string[], files?: string[]}.

public function projectDetectionConfig(): array

The current implementation checks for a single file:

KeyValue
files.github/copilot-instructions.md

The presence of .github/copilot-instructions.md signals that the project has been configured for GitHub Copilot. This is a standard GitHub Copilot customization file recognized by the IDE plugin.

Sources: src/PhpStormCopilot.php74-79 tests/Feature/PhpStormCopilotTest.php49-57


Runtime Environment Detection — isWSL()

The WithWSL trait provides isWSL(), which determines at runtime whether the PHP process is executing inside WSL:

protected function isWSL(): bool
{
 return ! empty(getenv('WSL_DISTRO_NAME'));
}

WSL_DISTRO_NAME is an environment variable automatically set by the WSL kernel for all processes running inside a WSL distribution. It is not present on native Linux, macOS, or Windows.

This check is used inside installFileMcp to branch into the WSL-specific installation pipeline instead of the standard file write. For the full installFileMcp dispatch logic, see MCP Configuration Generation.

Sources: src/Concerns/WithWSL.php11-14 src/PhpStormCopilot.php119-132


Detection Method Relationships

Diagram: Detection methods — classes and their roles


Sources: src/PhpStormCopilot.php1-67 src/Concerns/WithWSL.php1-14


How Detection Feeds Into Installation

Diagram: Detection gates in installFileMcp


Sources: src/PhpStormCopilot.php119-132 src/Concerns/WithWSL.php11-14


mcpConfigPath() — Where to Write mcp.json

mcpConfigPath() uses Platform::current() to determine the write location for mcp.json. This is separate from systemDetectionConfig (which detects whether PhpStorm is installed) — mcpConfigPath determines where the configuration file must be written for the GitHub Copilot plugin to read it.

Platform::current() resultWrite 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

When running in WSL, Platform::current() returns Platform::Linux, but the WSL branch in installFileMcp intercepts the call before mcpConfigPath is used for writing — instead, installMcpViaWsl determines the target Windows path by calling wslvar LOCALAPPDATA via a subprocess.

Sources: src/PhpStormCopilot.php104-114 src/Concerns/WithWSL.php16-76