vscode-phpserver icon indicating copy to clipboard operation
vscode-phpserver copied to clipboard

Failed To Open Stream

Open Oliver-Turp opened this issue 4 years ago • 3 comments

Been working fine for weeks, now I'm having a fatal error:

VSCode Logs:

[Sat May 1 20:12:46 2021] PHP 8.0.3 Development Server (http://localhost:3000) started

[Sat May 1 20:12:51 2021] [::1]:53146 Accepted

[Sat May 1 20:12:51 2021] PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0

[Sat May 1 20:12:51 2021] PHP Fatal error: Failed opening required 'c:\Users\Oliver Turp.vscode\extensions\brapifra.phpserver-3.0.2\src\server\logger.php' (include_path='E:\Programs\XAMPP\php\PEAR') in Unknown on line 0

[Sat May 1 20:12:51 2021] [::1]:53146 Closing

[Sat May 1 20:12:52 2021] [::1]:53156 Accepted

[Sat May 1 20:12:54 2021] PHP Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0

[Sat May 1 20:12:54 2021] PHP Fatal error: Failed opening required 'c:\Users\Oliver Turp.vscode\extensions\brapifra.phpserver-3.0.2\src\server\logger.php' (include_path='E:\Programs\XAMPP\php\PEAR') in Unknown on line 0

[Sat May 1 20:12:54 2021] [::1]:53156 Closing

Window Snip: image

Oliver-Turp avatar May 01 '21 19:05 Oliver-Turp

hi, i have the same problem could you solve it?

lucalquemist avatar Jun 07 '21 01:06 lucalquemist

hi, i have the same problem could you solve it?

No. Had to do a fresh install of VSCode and XAMP... for some reason it started working again :/

Oliver-Turp avatar Jun 07 '21 11:06 Oliver-Turp

Hello there. Below, there is the code to fix the issue. You first need to create a file with the name logger.php and then add the next chunk of code inside. Note: Be sure to create the logger file within the directory. C:\Users\User.vscode\extensions\brapifra.phpserver-3.0.2\src\server

<?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; ?>

josue-fdev avatar Mar 12 '22 03:03 josue-fdev