php-debugbar
php-debugbar copied to clipboard
open_basedir problem in Windows for getXdebugLink
Hello,
Laravel: 10 OS: Windows + Plesk PHP: 8.2.14
I'm getting an error in the debugbar when loading views into it. The view collector calls to DataCollector->getXdebugLink() and then it does the next call:
if (file_exists($file)) {
$file = realpath($file);
}
The error that arises is:
file_exists(): open_basedir restriction in effect. File(\resources\views\...pathtobladefile.blade.php) is not within the allowed path(s): (PATH_TO_THE_SITE\;C:\Windows\Temp\)
As far as I've been able to ascertain file_exists is trying to look for "C:\resources\views...pathtobladefile.blade.php" instead of "PATH_TO_THE_SITE\resources\views...pathtobladefile.blade.php" because it's not a relative path, it starts with "" and it understands it as / in UNIX and "C:" in Windows.
That's why the "open basedir" error arises because the path is wrong.
I've added this line in the DataCollector/DataCollector.php file:
if (empty($file)) {
return null;
}
$file = base_path() . $file; // <- This is new
if (file_exists($file)) {
$file = realpath($file);
}
Not sure if it will break UNIX based servers, that's why I'm not pushing a Pull Request
This is a pure php package
is base_path
a laravel helper?? Yes
Oh, I see, I'm using Laravel debug bar that uses this package. I'm not sure how to make a pure php version, maybe something using $_SERVER['DOCUMENT_ROOT'] but laravel's index.php is in a "public" subfolder from the document root but this is not true or other php apps :S
@thecko hi, try #590 and let your review there