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

Errors on windows setup #6

Open
dotmot opened this issue Dec 13, 2024 · 3 comments
Open

Errors on windows setup #6

dotmot opened this issue Dec 13, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@dotmot
Copy link

dotmot commented Dec 13, 2024

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

@dotmot dotmot added the bug Something isn't working label Dec 13, 2024
@robsontenorio
Copy link
Owner

Cc @roberto-proj

@nerisonpitogo
Copy link

nerisonpitogo commented Dec 13, 2024

Watch Josh Cirre's youtube and followed all steps. Had the same problem right now. I'm on windows machine.

@robsontenorio
Copy link
Owner

Unfortunately it is not ready for windows. Will take a look soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants