Tracking down problem areas in your code can be tricky and time consuming. You may already be aware that in your development environment, Symfony very helpfully reports problems to you by way of a Stack Trace:
But did you know you can improve on this output by turning the lines of code into clickable links that will load up your IDE of choice?
All we need to do is add in an
ide entry under the
framework configuration inside our
config.yml file and the very next time you see an error message like the above, you will have the ability to click on the file and be not only taken to that file, but your cursor will be placed on the very line of problematic code.
# app/config/config.yml framework: ide: 'phpstorm://open?file=%%f&line=%%l'
By the way, this isn't just a PHPStorm thing - you can use this for Sublime, or any other editor that allows files to be opened with a special file link format.
Now, depending on how you work this may or may not be useful to you.
Personally, I like to work using Virtual Machines - having my laptop (for example) running PHPStorm, a terminal session to the VM, and a MySQL client open as needed.
When I save a file it would be automatically uploaded to the virtual machine, where I have used Ansible to build the system to the exact same spec as what the real / production server(s) would be using. I do this because it removes many problems ("it works on my machine!"), and simplifies my life.
Unfortunately, doing this will cause an issue with the links that are generated. PHPStorm will try and open the absolute path of the file that lives on your server / Virtual Machine, rather than the local copy of the file. Which is... unfortunate.
I dug through the code that generates these links and couldn't find a solution to this problem.
However, this may be useful to you, so I wanted to share it anyway.