a-ok Posted February 8, 2021 Share Posted February 8, 2021 I was using MAMP for local development for years and Tracy never had any issues. I've recently just switched to using Laravel Valet with the custom driver and all seems okay but when I enable Tracy I get the following error. When I disable Tracey and debug `$_SERVER['REQUEST_URI']` it returns false. Any thoughts on how I can continue to use Tracy (which is so brilliant useful) when using Laravel Valet? Thanks! Link to comment Share on other sites More sharing options...
teppo Posted February 8, 2021 Share Posted February 8, 2021 Possibly related: 2 Link to comment Share on other sites More sharing options...
adrian Posted February 8, 2021 Share Posted February 8, 2021 In addition to the thread that @teppo linked to, also take a look at: https://github.com/adrianbj/TracyDebugger/issues/32 Not sure why Valet hasn't fixed it yet though. Link to comment Share on other sites More sharing options...
a-ok Posted February 8, 2021 Author Share Posted February 8, 2021 2 minutes ago, teppo said: Possibly related: Ah thanks @teppo I didn't manage to find this. Much appreciated. @adrian Thanks also! And yeah ? Link to comment Share on other sites More sharing options...
jploch Posted March 23, 2022 Share Posted March 23, 2022 I also have issues with tracy since I switched to laravel valet for my local development (Mac OSX Monterey). The panel is loading but I can not see field and template infos in the request info panel. Also I get an error when visiting a template settings page in the admin. The module works fine with the same setup (Site Export) on my shared hosting server. I access my site via http (http://projectname.test). Iam using Tracy version 4.23.25. Here is the template error: ErrorException: Undefined variable: template in /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php:572 Stack trace: #0 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/panels/RequestInfoPanel.php(572): Tracy\Bar->Tracy\{closure}(8, 'Undefined varia...', '/Users/jploch/S...', 572, Array) #1 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(141): RequestInfoPanel->getPanel() #2 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(113): Tracy\Bar->renderPanels('') #3 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Bar/Bar.php(87): Tracy\Bar->renderPartial('main') #4 /Users/jploch/Sites/PageGrid/dist/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/DevelopmentStrategy.php(138): Tracy\Bar->render(Object(Tracy\DeferredContent)) #5 /Users/jploch/Sites/PageGrid/dist/site/assets/cache/FileCompiler/site/modules/TracyDebugger/tracy-2.9.x/src/Tracy/Debugger/Debugger.php(315): Tracy\DevelopmentStrategy->renderBar() #6 [internal function]: Tracy\Debugger::shutdownHandler() #7 {main} I already tried this solution from the linked post above (changing the valet driver), with no success. Link to comment Share on other sites More sharing options...
adrian Posted March 23, 2022 Share Posted March 23, 2022 Hi @jploch - I actually have a feeling this isn't Valet related. It looks like a bug in the RequestInfo panel. Any chance you have turned off some of the sections within it, likely the Template Settings section? It's an easy fix, but just wanted to confirm that you do have this disabled. It's probably that one second from the top that is causing the problem. You might have upgraded from a really old version of Tracy when that section didn't exist. 1 Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 @jploch - it should be fixed in the latest version. 1 Link to comment Share on other sites More sharing options...
jploch Posted March 24, 2022 Share Posted March 24, 2022 @adrian Thx! That was fast! The error is gone now. However I still don't see the field and template infos in the request info panel on my local installation. Here is a screenshot of my local request info panel (Viewing the template settings page for template home) And here is a screenshot from my shared hosting, both have the new tracy version installed (Viewing the template settings page for template home) Both have these settings for the info request panel: Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 Hi @jploch - it looks like the issue is a problem with what $_SERVER['PHP_SELF'] is returning. Could you please add the following code to line #53 of the RequestInfoPanel.php file and let me know what is returned? bd($_SERVER['PHP_SELF'] . ' : ' . $this->wire('config')->urls->root . 'index.php'); 1 Link to comment Share on other sites More sharing options...
jploch Posted March 24, 2022 Share Posted March 24, 2022 6 minutes ago, adrian said: Could you please add the following code to line #53 of the RequestInfoPanel.php file and let me know what is returned? Thanks again for looking into this. Here is the dump return (local enviroment): '/admin/setup/template/edit : /index.php' Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 Interesting - Valet seems to mess with PHP_SELF. Could you please find out what bd($_SERVER['SCRIPT_NAME']); returns. It looks like there might be another option around setting: 'usePathInfo' => true in general.php (https://github.com/laravel/valet/issues/340) - is that something you are familiar with? I think general.php is a file in the Valet system, but not really sure. 1 Link to comment Share on other sites More sharing options...
jploch Posted March 24, 2022 Share Posted March 24, 2022 5 minutes ago, adrian said: Interesting - Valet seems to mess with PHP_SELF. Could you please find out what bd($_SERVER['SCRIPT_NAME']); returns. it returns: '/index.php' 10 minutes ago, adrian said: It looks like there might be another option around setting: 'usePathInfo' => true in general.php (https://github.com/laravel/valet/issues/340) - is that something you are familiar with? I think general.php is a file in the Valet system, but not really sure. I don't have the file general.php on my system. Maybe it's a Craft CMS thing? Maybe I can update the ProcessWireValetDriver.php file, which I think is doing everithing to make valet and ProcessWire work together. Iam not very exoerienced with valet and php in general, so I have no idea where to start. I got the file from this thread (not sure which version I picked). Here is the code a have in that file, if it helps: <?php class ProcessWireValetDriver extends BasicValetDriver { private $possibleDirectories = [ '', // PW in root, do not remove except you're sure you never use it '/dist', '/public' ]; /** * Determine if the driver serves the request. * * @param string $sitePath * @param string $siteName * @param string $uri * @return bool */ public function serves($sitePath, $siteName, $uri) { foreach ($this->possibleDirectories as $dir) { if(is_dir("{$sitePath}{$dir}/wire")) return true; } return false; } public function isStaticFile($sitePath, $siteName, $uri) { foreach ($this->possibleDirectories as $dir) { if(is_file($staticFilePath = "{$sitePath}{$dir}{$uri}")) return $staticFilePath; } return false; } /** * Get the fully resolved path to the application's front controller. * * @param string $sitePath * @param string $siteName * @param string $uri * @return string */ public function frontControllerPath($sitePath, $siteName, $uri) { $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; $_SERVER['SCRIPT_NAME'] = '/index.php'; $_GET['it'] = $uri; if ($uri === '') { $uri = '/'; } foreach ($this->possibleDirectories as $dir) { if(!file_exists($indexPath = "{$sitePath}{$dir}/index.php")) continue; // $_SERVER['REQUEST_URI'] = substr(str_replace($dir, '', $_SERVER['REQUEST_URI']), 10); $_SERVER['SCRIPT_FILENAME'] = $indexPath; if (file_exists($indexPath = "{$sitePath}{$dir}/install.php")) { return $indexPath; } return parent::frontControllerPath( "{$sitePath}{$dir}", $siteName, $uri ); } } } Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 @jploch - thanks for those. I am honestly not sure the best approach to fix this. The problem in question is this: // check if request is to a PW page - otherwise it's maybe an AJAX request to an external script $isPwPage = $_SERVER['PHP_SELF'] == $this->wire('config')->urls->root . 'index.php' ? true : false; But, I can't seem to trigger a situation at the moment where this returns false (even making an ajax request to an external script). I don't think I want to replace PHP_SELF with SCRIPT_NAME because I think that would return an incorrect result if the external script was an index.php file. Possibly you could add: $_SERVER['PHP_SELF'] = '/index.php'; to the frontControllerPath() method. I expect that will fix things, but not sure if there might be some side effects, but it might be the best solution. Let me know it that works for you. 1 Link to comment Share on other sites More sharing options...
jploch Posted March 24, 2022 Share Posted March 24, 2022 @adrian I added that line to the function and restartet valet, but nothing changed as far as I can tell. I still don't see the field and template infos in the request info panel Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 What does that original: bd($_SERVER['PHP_SELF'] . ' : ' . $this->wire('config')->urls->root . 'index.php'); return now? 1 Link to comment Share on other sites More sharing options...
jploch Posted March 24, 2022 Share Posted March 24, 2022 @adrian it still returns the same: '/admin/setup/template/edit : /index.php' Link to comment Share on other sites More sharing options...
adrian Posted March 24, 2022 Share Posted March 24, 2022 1 hour ago, jploch said: @adrian it still returns the same: '/admin/setup/template/edit : /index.php' Weird - I have no idea why that would be happening - maybe it can't be overwritten in Valet for some reason? There might be a better way for me to check if the request is a response from PW page or not, but I am hesitant to change the current logic without understanding things a bit better. Any Valet experts out there who have an idea on what the best way forward is? Link to comment Share on other sites More sharing options...
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