bernhard Posted July 20 Posted July 20 Hey @adrian this is a bit special, but maybe it's an easy fix, I don't know 🙂 I love these direct IDE links in dumps that open up the file in question right in my IDE when clicked: The problem is that @Sanyaissues and I have been working on improving RockMigrations deployments and Michael also suggested to put all PW files into /public This leads to a folder structure like this: /Users/bernhard/projectx /public /site /wire /src foo.latte bar.latte When I set localRootPath to /Users/bernhard/projectx/public/ links for files inside the PW root work (eg /site/ready.php) BUT links for files to /src/foo.latte do not 😞 I have all my latte files outside of /public. Also all assets (css/js) are in the /src folder and then compiled, merged and minified via RockDevTools to /public/dst I was hesitant to go with such a setup at first because I was expecting issues. I already had to refactor my modules to support that setup and there are likely some spots still to fix. But I think it is a great setup and it is worth the effort. What do you think? Is that something you could support for tracy debugger as well? Maybe it's just do add a new (optional) setting like "projectRoot" so that paths to can properly be rewritten: /var/www/html/src/foo.latte /Users/bernhard/projectx/src/foo.latte /var/www/html/public/site/ready.php /Users/bernhard/projectx/public/site/ready.php At the moment the result is this: /var/www/html/src/foo.latte /var/www/html/src/foo.latte /var/www/html/public/site/ready.php /Users/bernhard/projectx/public/site/ready.php I guess it's because it does not find $config->paths->root in the filename and thus does not apply a str_replace? Thx a lot in advance 🙂 1
adrian Posted July 21 Posted July 21 Hey @bernhard - does everything work as needed if you replace all instances of $config->paths->root on these lines (https://github.com/adrianbj/TracyDebugger/blob/40cfe39239ea1fb2d6ee50920ebc9f3f86b21048/TracyDebugger.module.php#L1058-L1071) with your project root? Or are other changes needed?  1
bernhard Posted July 22 Author Posted July 22 Hey @adrian that works! I added a pull request for that and also added another one to improve dumps when using latte. The problem here is that when using latte files and adding a {bd('whatever')} in those files tracy actually picks up the compiled cache file and not the source file: source: /site/templates/latte/includes/foo.latte cache: /site/assets/cache/Latte/latte-includes-foo.php The implementation is kinda hacky and uses rockfrontend's dom tools to parse the html content of the dumps panel and then rewrite it to my needs. I didn't find a better option to modify what tracy puts in its bd() editorlinks output. If you know one let me know!
adrian Posted July 27 Posted July 27 Hey @bernhard - I am not sure if this works for all your needs, but you should be able to add to the array of path replacements whenever/wherever you want. For example: \Tracy\Debugger::$editorMapping['/assets/cache/Latte/latte-includes-foo.php'] = '/templates/latte/includes/foo.latte'; I feel like you could probably build out all the replacements you need by looping over the files in /assets/cache/Latte/ and replacing the path and filename as needed with some pretty simple logic. I feel like this should allow you to handle both scenarios in your recent PRs without changes to Tracy. Sound OK, or am I missing something? 1
adrian Posted July 30 Posted July 30 Hey @bernhard - are you happy with this solution? Can I close: https://github.com/adrianbj/TracyDebugger/pull/105 ?
bernhard Posted August 3 Author Posted August 3 @adrian unfortunately I'm lost with this and need some more help 😞 Where would I put this mapping and what would I place as patterns? It feels complicated to me and I'm a bit afraid of doing this for each and every project 😮 I have a wrong return value in Editor.php on line 49 which throws a bluescreen like this: As you can see the path to that file shows /example.com/site/modules/.../Editor.php The tooltip shows the correct path in the DDEV web container: /public/site/modules... When I click the link it tries to open that folder in Cursor, but without the needed /public and therefore it does not find the file: I'm totally lost and I hope you have an idea?
adrian Posted August 5 Posted August 5 Hey @bernhard - you can put it anywhere (so long as Tracy is loaded, which basically excludes config.php, but it works in init.php, ready.php, etc. Or you could put it in any module file that is loaded everywhere. Another very simple test that adds "/test/" to the path and will work for all editor links.      \Tracy\Debugger::$editorMapping['/site/templates/'] = '/site/templates/test/'; Can you share what values you've been trying to add to $editorMapping so I can maybe see why it's not working?
bernhard Posted August 17 Author Posted August 17 Got it working, thank you very much! 🙂 If anybody else if having trouble, here is how to do it: First, add this to your ddev config: web_environment: - TRACY_LOCALROOTPATH=$DDEV_APPROOT/ This will add the path of the project root as getenv('TRACY_LOCALROOTPATH') in the web container so that you don't have a hardcoded path in your config. Next add these mappings in init.php: \Tracy\Debugger::$editorMapping['/var/www/html/public/'] = getenv('TRACY_LOCALROOTPATH') . 'public/'; \Tracy\Debugger::$editorMapping['/var/www/html/src/'] = getenv('TRACY_LOCALROOTPATH') . 'src/';  1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now