PHP error with "logger.php" - Unknown: Failed to open stream: No such file or directory in Unknown on line 0
I'm using Visual Studio Code with PHP Server extension. When I try to launch my Web application, the browser shows me this message:
Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Failed opening required 'c:\Users\OMISSIS\.vscode\extensions\brapifra.phpserver-3.0.2\src\server\logger.php' (include_path='C:\xampp\php\PEAR') in Unknown on line 0
I also tried to reinstall VS Code and XAMPP but the problem persists. What can I do?
For some reason, the file logger.php
(belonging to the PHP Server extension) is missing.
The solution is creating it (in the path indicated in the error message) with the following content:
<?php
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$relativePath = getenv('PHP_SERVER_RELATIVE_PATH');
$fullPath = $_SERVER["DOCUMENT_ROOT"] . $relativePath . $path;
if (!file_exists($fullPath) || is_dir($fullPath)) {
file_put_contents("php://stderr", sprintf("[%s] %s", date("D M j H:i:s Y"), "[404] $path - No such file or directory "));
}
else {
file_put_contents("php://stdout", sprintf("[%s] %s", date("D M j H:i:s Y"), "[200] $path"));
}
return false;
?>