Symfony: Open file in VSCode or PHPStorm from the browser
April 30th, 2020
I've been working on a Symfony project recently and have been seeing lots of Exceptions in my browser. These are great - except its sometimes a pain to navigate to the file in your ide.
A cool feature of Symfony is that you can configure your application to open files from your browser directly in your IDE. This is great when working with PHPStorm or VSCode.
To do this, add the IDE line to your
# config/packages/framework.yaml framework: ... ide: "vscode://file/%%f:%%l” # or ide: "phpstorm://open?file=%%f&line=%%l”
Then reload your browser with a page showing Exceptions and click on one of the filenames. Your browser should ask to open the file in the ide.
It gets better. You can also open files directly in your IDE from the Debug Bar! Make sure you're running a site in dev mode and have the debug bar enabled, then navigate to a working page. Click on the Twig templating section of the debug bar, then click on the filename of any of the templates; it should open in PHPStorm or VSCode.