Add Laravel IDE discovery files for VS Code integration

- Introduced multiple discovery files to enhance Laravel IDE support in Visual Studio Code.
- Implemented functionality to retrieve and parse test cases, translations, Livewire components, and middleware information.
- Enhanced error handling and logging configurations for better debugging experience.
- Utilized Laravel's service provider for bootstrapping necessary configurations.
This commit is contained in:
2026-03-16 19:55:20 -04:00
parent 26d4f5d175
commit 56462aac19
17 changed files with 3160 additions and 59 deletions

View File

@@ -0,0 +1,79 @@
<?php
error_reporting(E_ERROR | E_PARSE);
define('LARAVEL_START', microtime(true));
require_once __DIR__ . '/../autoload.php';
class LaravelVsCode
{
public static function relativePath($path)
{
if (!str_contains($path, base_path())) {
return (string) $path;
}
return ltrim(str_replace(base_path(), '', realpath($path) ?: $path), DIRECTORY_SEPARATOR);
}
public static function isVendor($path)
{
return str_contains($path, base_path("vendor"));
}
public static function outputMarker($key)
{
return '__VSCODE_LARAVEL_' . $key . '__';
}
public static function startupError(\Throwable $e)
{
throw new Error(self::outputMarker('STARTUP_ERROR') . ': ' . $e->getMessage());
}
}
try {
$app = require_once __DIR__ . '/../../bootstrap/app.php';
} catch (\Throwable $e) {
LaravelVsCode::startupError($e);
exit(1);
}
$app->register(new class($app) extends \Illuminate\Support\ServiceProvider
{
public function boot()
{
config([
'logging.channels.null' => [
'driver' => 'monolog',
'handler' => \Monolog\Handler\NullHandler::class,
],
'logging.default' => 'null',
]);
}
});
try {
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();
} catch (\Throwable $e) {
LaravelVsCode::startupError($e);
exit(1);
}
echo LaravelVsCode::outputMarker('START_OUTPUT');
echo json_encode([
'page_extensions' => config('inertia.page_extensions', config('inertia.testing.page_extensions', [])),
'page_paths' => collect(config('inertia.page_paths', config('inertia.testing.page_paths', [])))->flatMap(function($path) {
$relativePath = LaravelVsCode::relativePath($path);
return [$relativePath, mb_strtolower($relativePath)];
})->unique()->values(),
]);
echo LaravelVsCode::outputMarker('END_OUTPUT');
exit(0);