brapifra / vscode-phpserver

Visual Studio Code extension to quickly serve your PHP projects :)
88 stars 29 forks source link

Failed To Open Stream #93

Open Oliver-Turp opened 3 years ago

Oliver-Turp commented 3 years ago

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

lucalquemist commented 3 years ago

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

Oliver-Turp commented 3 years ago

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 :/

josue-fdev commented 2 years ago

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