-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
Component discovery fails with symlinked packages outside project directory
Description
When using Composer path repositories with symlinks pointing to packages outside the project directory, the extension fails to discover Blade components with a file_get_contents error.
Error Message
ErrorException
file_get_contents(C:\laragon6\www\cegrad3beta\C:\laragon6\www\packages\laravel-layout-system\resources\views\components\content\page-header.blade.php): Failed to open stream: No such file or directory
at vendor\_laravel_ide\discover-*.php:418
protected function parseProps($compiler, array $component): ?string
{
$content = file_get_contents(base_path($component['path']));
Root Cause
The issue is in the parseProps method at line 418 of the discovery script:
$content = file_get_contents(base_path($component['path']));When a package is symlinked from outside the project (e.g., ../packages/laravel-layout-system), the component path is resolved to an absolute path:
C:\laragon6\www\packages\laravel-layout-system\resources\views\components\content\page-header.blade.php
Then base_path() prepends the project path, resulting in an invalid double path:
C:\laragon6\www\cegrad3beta\C:\laragon6\www\packages\laravel-layout-system\...
Suggested Fix
Check if the path is already absolute before calling base_path():
protected function parseProps($compiler, array $component): ?string
{
$path = $component['path'];
// Check if path is already absolute (Windows or Unix)
$isAbsolute = preg_match('/^([a-zA-Z]:\\\\|\\/)/', $path);
$fullPath = $isAbsolute ? $path : base_path($path);
$content = file_get_contents($fullPath);
// ...
}Environment
- Extension version: 1.5.1
- OS: Windows 11
- PHP Environment: Laravel Herd
composer.json (relevant part)
{
"repositories": {
"laravel-layout-system": {
"type": "path",
"url": "../packages/laravel-layout-system",
"options": {
"symlink": true
}
}
}
}Workaround
Disable Blade component features in .vscode/settings.json:
{
"Laravel.bladeComponent.link": false,
"Laravel.bladeComponent.completion": false,
"Laravel.bladeComponent.hover": false
}Steps to Reproduce
- Create a Laravel project
- Create a package outside the project directory with Blade components
- Add it as a Composer path repository with symlink
- Open the project in VS Code with the Laravel extension
- Observe the error in the Output panel (Laravel channel)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels