-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve fileLinkFormat / SYMFONY_IDE configuration outside Symfony #50619
Comments
are you sure? it works for me in framework context, but it should work everywhere IMHO we havent configured |
Just tested and confirm path mapping won't work in standalone mode: <?php
$_ENV['SYMFONY_IDE'] = 'vscode://file/%f:%l&/user/name/sites/issue-50619/>/projects/my_project/'; # Don't work :(
// $_ENV['SYMFONY_IDE'] = 'vscode://file/%f:%l'; # Works fine :)
// $_ENV['SYMFONY_IDE'] = 'vscode'; # Works fine :)
use Symfony\Component\ErrorHandler\Debug;
require_once 'vendor/autoload.php';
Debug::enable();
trigger_error('This is an error', E_USER_ERROR);
// Getting link
// vscode://file//user/name/sites/issue-50619/index.php:13&/user/name/sites/issue-50619/>/projects/my_project/
That's what I think too 🙂 |
This comment was marked as resolved.
This comment was marked as resolved.
the issue is in fix: - $fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? null;
+ $fileLinkFormat ??= new FileLinkFormatter(); |
This one resolves the issue with the Maybe the same kind of logic could be applied to the |
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class) - Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class) - Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class) - Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class) - Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
Description
Hello,
I mostly use Symfony components in a standalone way (outside Symfony Framework) and sometimes find quite hard to handle the
fileLinkFormat
globally.error-handler
symfony/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php
Lines 55 to 58 in 42d43b7
Although it has been easier to setup since
SYMFONY_IDE
env var was introduced, this works perfectly if you don't use a container (Docker, etc.). But the link format described here to handle path mapping won't work with the onlySYMFONY_IDE
env var set. In such case, you will have to set a custom exception handler overriding the default one here:symfony/src/Symfony/Component/ErrorHandler/ErrorHandler.php
Lines 647 to 662 in 42d43b7
Just to provide a default
new FileLinkFormatter()
object to theHtmlErrorRenderer
renderer.And this will only work for Html errors since the CliErrorRenderer will use the
var-dumper
component.var-dumper
In a non Symfony app, the
var-dumper
will almost always fall into the default case here:symfony/src/Symfony/Component/VarDumper/VarDumper.php
Lines 91 to 92 in 42d43b7
If you want your links to be fully functional (e.g. path mapping replacements working in a docker context), you'll have to override the handler:
It would nice to make fileLinkFormat more easily consistent/configurable when used outside Symfony.
Example
No response
The text was updated successfully, but these errors were encountered: