Skip to content
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

[Bug]: No usable PHP version found #214

Open
filasik opened this issue Jan 20, 2025 · 1 comment
Open

[Bug]: No usable PHP version found #214

filasik opened this issue Jan 20, 2025 · 1 comment
Assignees
Labels

Comments

@filasik
Copy link

filasik commented Jan 20, 2025

Extension Version

0.1.18

PHP Binary

Local PHP

Operating System

Windows

What happened?

I start VSCode, once extension boots up i got this error:

`
2025-01-20 10:08:32.513 [error] Error:

'""No' is not recognized as an internal or external command,
operable program or batch file.

2025-01-20 10:08:32.513 [error] ""No usable PHP version found"" "c:\inetpub\wwwroot\mhv\vendor_laravel_ide\discover-3e2e90ed831bcc0de1ed14119ef5173f.php"
2025-01-20 10:08:32.513 [error] '""No' is not recognized as an internal or external command,
operable program or batch file.

2025-01-20 10:08:32.513 [error] Error:

'""No' is not recognized as an internal or external command,
operable program or batch file.

2025-01-20 10:08:32.513 [error] ""No usable PHP version found"" "c:\inetpub\wwwroot\mhv\vendor_laravel_ide\discover-901610af9ad0957af18489de07ea4347.php"
2025-01-20 10:08:32.513 [error] '""No' is not recognized as an internal or external command,
operable program or batch file.

2025-01-20 10:08:32.513 [info] Activating Laravel Extension...
2025-01-20 10:08:32.513 [info] Started`

PHP file content:

`<?php

error_reporting(E_ERROR | E_PARSE);

define('LARAVEL_START', microtime(true));

require_once DIR . '/../autoload.php';
$app = require_once DIR . '/../../bootstrap/app.php';

class VsCodeLaravel extends \Illuminate\Support\ServiceProvider
{
public function register()
{
}

public function boot()
{
    config([
        'logging.channels.null' => [
            'driver' => 'monolog',
            'handler' => \Monolog\Handler\NullHandler::class,
        ],
        'logging.default' => 'null',
    ]);
}

}

function vsCodeToRelativePath($path)
{
if (!str_contains($path, base_path())) {
return (string) $path;
}

return ltrim(str_replace(base_path(), '', realpath($path)), DIRECTORY_SEPARATOR);

}

$app->register(new VsCodeLaravel($app));
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

echo 'VSCODE_LARAVEL_START_OUTPUT';

function vsCodeFindBladeFiles($path)
{
$paths = [];

if (!is_dir($path)) {
return $paths;
}

foreach (
\Symfony\Component\Finder\Finder::create()
->files()
->name("*.blade.php")
->in($path)
as $file
) {
$paths[] = [
"path" => str_replace(base_path(DIRECTORY_SEPARATOR), '', $file->getRealPath()),
"isVendor" => str_contains($file->getRealPath(), base_path("vendor")),
"key" => \Illuminate\Support\Str::of($file->getRealPath())
->replace(realpath($path), "")
->replace(".blade.php", "")
->ltrim(DIRECTORY_SEPARATOR)
->replace(DIRECTORY_SEPARATOR, ".")
];
}

return $paths;
}
$paths = collect(
app("view")
->getFinder()
->getPaths()
)->flatMap(function ($path) {
return vsCodeFindBladeFiles($path);
});

$hints = collect(
app("view")
->getFinder()
->getHints()
)->flatMap(function ($paths, $key) {
return collect($paths)->flatMap(function ($path) use ($key) {
return collect(vsCodeFindBladeFiles($path))->map(function ($value) use (
$key
) {
return array_merge($value, ["key" => "{$key}::{$value["key"]}"]);
});
});
});

[$local, $vendor] = $paths
->merge($hints)
->values()
->partition(function ($v) {
return !$v["isVendor"];
});

echo $local
->sortBy("key", SORT_NATURAL)
->merge($vendor->sortBy("key", SORT_NATURAL))
->toJson();
;
echo 'VSCODE_LARAVEL_END_OUTPUT';

exit(0);
`

@lecano
Copy link

lecano commented Jan 21, 2025

Image

I had to set the PHP environment to 'local' (ensure the PHP path is added to the environment variables on Windows). If the PHP environment setting is set to auto-detect, it will check 'local' last and fail (timeout?). I don't use Herd because adding additional PHP extensions don't work on my Windows/Herd machine, so my remaining options are 'local' or docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants