Skip to content

Errors on windows setupΒ #6

@dotmot

Description

@dotmot

Voltage version

1.3.0

VSCode version

1.96.0

Laravel version

11.35.1

Livewire version

3.5.17

What happened?

I installed the extension and i get the following error.
❌ Vendor directory not found. Please, run 'composer install'.

Playing a bit with the out\server\src\voltage.js i got it to find the vendor folder by changing the following line

let e = t.workspaceFolders[0]?.uri.replace('file://', '');

to

let e = t.rootPath;

This change gets me to
πŸŒ€ Scaning container ...
But it fails with
PHP Parse error: syntax error, unexpected string content "require", expecting end of file in Command line code on line 1

If i change the follwing code

            let e = Ee.getInstance().get("rootPath"),
                i = `require "${e}/vendor/autoload.php";
                $app = require "${e}/bootstrap/app.php";
                $kernel = $app->make(Illuminate\\Contracts\\Console\\Kernel::class);
                $kernel->bootstrap();

                $components = Illuminate\\Support\\Facades\\Blade::getClassComponentAliases();
                $allComponents = [];

                foreach ($components as $alias => $class) {
                    try {
                        $reflection = new ReflectionClass($class);
                        $allComponents[] = [
                            "alias" => $alias,
                            "path" => $reflection->getFileName(),
                        ];
                    } catch (ReflectionException $e) {
                        // Do nothing
                    }
                }

                // Get extra anonymous components paths
                $anonymousPaths = Illuminate\\Support\\Facades\\Blade::getAnonymousComponentPaths();
                $allPaths = [];

                foreach ($anonymousPaths as $path) {
                    $allPaths[] = [
                        "path" => realpath($path["path"]),
                        "prefix" => $path["prefix"]
                    ];
                }

                $spy = [
                    "components" => $allComponents,
                    "componentsAnonymousPaths" => $allPaths,
                ];

                echo json_encode($spy);`,

and add

<?php ... ?>

it fails with
The filename, directory name, or volume label syntax is incorrect.

Now if i run the code as a php file

<?php

require 'C:\www\{folder}/vendor/autoload.php';

$app = require 'C:\www\{folder}/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
$kernel->bootstrap();

$components = Illuminate\Support\Facades\Blade::getClassComponentAliases();
$allComponents = [];

foreach ($components as $alias => $class) {
  try {
    $reflection = new ReflectionClass($class);
    $allComponents[] = [
      'alias' => $alias,
      'path' => $reflection->getFileName(),
    ];
  } catch (ReflectionException $e) {
    // Do nothing
  }
}

// Get extra anonymous components paths
$anonymousPaths = Illuminate\Support\Facades\Blade::getAnonymousComponentPaths();
$allPaths = [];

foreach ($anonymousPaths as $path) {
  $allPaths[] = [
    'path' => realpath($path['path']),
    'prefix' => $path['prefix'],
  ];
}

$spy = [
  'components' => $allComponents,
  'componentsAnonymousPaths' => $allPaths,
];

echo json_encode($spy);

i get what i assume is the intended output
{"components":[{"alias":"dynamic-component","path":"C:\\www\\{folder}\\vendor\\laravel\\framework\\src\\Illuminate\\View\\DynamicComponent.php"}],"componentsAnonymousPaths":[]}

I also had to add
set to NODE_OPTIONS=--no-warnings npx prettier ${this.tempFile} --config ${n} --write

I know nothing about vscode extension development but hope this helps make this extension better

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions