Skip to content

refactor: streamline path resolution and simplify the MCP client interface #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ private function installMcpServerConfig(): void
$this->output->write(" {$ideDisplay}... ");
$results = [];

$php = $this->getPhpPathForMcpClient($mcpClient);
$php = $mcpClient->getPhpPath();
if ($this->shouldInstallMcp()) {
try {
$artisan = $this->getArtisanPathForMcpClient($mcpClient);
$artisan = $mcpClient->getArtisanPath();
$result = $mcpClient->installMcp('laravel-boost', $php, [$artisan, 'boost:mcp']);

if ($result) {
Expand All @@ -492,7 +492,7 @@ private function installMcpServerConfig(): void
try {
$result = $mcpClient->installMcp(
key: 'herd',
command: $this->getPhpPathForMcpClient($mcpClient),
command: $mcpClient->getPhpPath(),
args: [$this->herd->mcpPath()],
env: ['SITE_PATH' => base_path()]
);
Expand Down Expand Up @@ -524,16 +524,6 @@ private function installMcpServerConfig(): void
}
}

private function getPhpPathForMcpClient(McpClient $mcpClient): string
{
return $mcpClient->useAbsolutePathForMcp() ? PHP_BINARY : 'php';
}

private function getArtisanPathForMcpClient(McpClient $mcpClient): string
{
return $mcpClient->useAbsolutePathForMcp() ? base_path('artisan') : './artisan';
}

/**
* Is the project actually using localization for their new features?
*/
Expand Down
10 changes: 10 additions & 0 deletions src/Contracts/McpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ public function mcpClientName(): ?string;
*/
public function useAbsolutePathForMcp(): bool;

/**
* Get the PHP executable path for this MCP client.
*/
public function getPhpPath(): string;

/**
* Get the artisan path for this MCP client.
*/
public function getArtisanPath(): string;

/**
* Install an MCP server configuration in this IDE.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Install/CodeEnvironment/CodeEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ public function useAbsolutePathForMcp(): bool
return $this->useAbsolutePathForMcp;
}

public function getPhpPath(): string
{
return $this->useAbsolutePathForMcp() ? PHP_BINARY : 'php';
}

public function getArtisanPath(): string
{
return $this->useAbsolutePathForMcp() ? getcwd().'/artisan' : './artisan';

}

/**
* Get the detection configuration for system-wide installation detection.
*
Expand Down
37 changes: 0 additions & 37 deletions tests/Unit/Console/InstallCommandPhpPathTest.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

declare(strict_types=1);

use Laravel\Boost\Install\CodeEnvironment\Cursor;
use Laravel\Boost\Install\CodeEnvironment\PhpStorm;
use Laravel\Boost\Install\Detection\DetectionStrategyFactory;

test('PhpStorm returns absolute PHP_BINARY path', function () {
$strategyFactory = Mockery::mock(DetectionStrategyFactory::class);
$phpStorm = new PhpStorm($strategyFactory);

expect($phpStorm->getPhpPath())->toBe(PHP_BINARY);
});

test('PhpStorm returns absolute artisan path', function () {
$strategyFactory = Mockery::mock(DetectionStrategyFactory::class);
$phpStorm = new PhpStorm($strategyFactory);

$artisanPath = $phpStorm->getArtisanPath();

// Should be an absolute path ending with 'artisan'
expect($artisanPath)->toEndWith('artisan')
->and($artisanPath)->not()->toBe('./artisan');
});

test('Cursor returns relative php string', function () {
$strategyFactory = Mockery::mock(DetectionStrategyFactory::class);
$cursor = new Cursor($strategyFactory);

expect($cursor->getPhpPath())->toBe('php');
});

test('Cursor returns relative artisan path', function () {
$strategyFactory = Mockery::mock(DetectionStrategyFactory::class);
$cursor = new Cursor($strategyFactory);

expect($cursor->getArtisanPath())->toBe('./artisan');
});