Jonathan Lahijani Posted May 11, 2023 Share Posted May 11, 2023 I wanted to share the way I enable Tracy Debugger for myself (a superuser) and myself only, only when logged in. This is useful if there are other superusers that are not developers and you don't want them to see the Tracy Debugger bar. There's a variety of settings and methods related to this, but I wanted to distill it into a few short steps: create a permission called 'tracy-debugger' (note: Tracy Debugger doesn't create this permission for you during installation) create a role called 'developer' (sounds like the right name to me) assuming you're a superuser, edit your account and assign the 'developer' role; if there are multiple developers on the project, consider assigning them this role as well in Tracy Debugger's settings do the following: Main Setup → Output Mode → DEVELOPMENT Access Permission → Restrict Superusers → checked Link to comment Share on other sites More sharing options...
adrian Posted May 11, 2023 Share Posted May 11, 2023 Hi @Jonathan Lahijani - thanks for the write-up. You mention "myself only", so perhaps that's the reason for your approach - so other superusers don't have Tracy running in DEV mode? Is that the key functionality of this approach that you needed? Otherwise, I think you might be confused about Tracy's DEVELOPMENT vs PRODUCTION modes. DEV mode is what enables the debug bar, while production mode runs Tracy in the background, logging and notifying errors (via email and / or Slack). It's not about whether your install is DEV or PROD. I just set to PROD mode and use the "Force superusers into DEVELOPMENT mode" option so that DEV mode is enabled for me (and other superusers) regardless of whether we are on the dev or prod servers. Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted May 11, 2023 Author Share Posted May 11, 2023 (edited) 7 minutes ago, adrian said: Hi @Jonathan Lahijani - thanks for the write-up. You mention "myself only", so perhaps that's the reason for your approach - so other superusers don't have Tracy running in DEV mode? Is that the key functionality of this approach that you needed? That's correct. I oftentimes have non-developers set as the Superuser role, but I wouldn't want them to see the Tracy Debugger bar. Edit: I should reword my explanation as my usage of Development and Production is confusing within the context of Tracy Debugger. Edited May 11, 2023 by Jonathan Lahijani 1 Link to comment Share on other sites More sharing options...
bernhard Posted May 12, 2023 Share Posted May 12, 2023 What about this in ready.php? if ($user->name !== 'thatsme') \Tracy\Debugger::$showBar = false; 1 Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted May 18, 2023 Author Share Posted May 18, 2023 @adrian Based on my approach above, which I'd like to keep, I additionally also want to enable TD development mode if I'm a guest and it matches my specific IP address. Is that possible? The way the allowedTracyUser method is written seems to suggest it is not. Link to comment Share on other sites More sharing options...
bernhard Posted May 19, 2023 Share Posted May 19, 2023 @Jonathan Lahijani why don't you just use a separate config-local.php where you set guestForceDevelopmentLocal = true? Such a dedicated config has a lot of other benefits like disabling sessionFingerprint to make sure you don't get logged out when you enable mobile view in devtools or filesOnDemand when using RockMigrations: Link to comment Share on other sites More sharing options...
Jonathan Lahijani Posted May 25, 2023 Author Share Posted May 25, 2023 On 5/19/2023 at 12:56 AM, bernhard said: @Jonathan Lahijani why don't you just use a separate config-local.php where you set guestForceDevelopmentLocal = true? Such a dedicated config has a lot of other benefits like disabling sessionFingerprint to make sure you don't get logged out when you enable mobile view in devtools or filesOnDemand when using RockMigrations: @bernhard My current strategy for detecting development/staging/production environment is currently based on using gethostname() or server_name, depending on the site and setting a custom $config->env variable. Eventually I will switch to a cleaner way when Ryan hopefully officially implements something more formal. I saw your PR and have read the various discussions on this topic. That aside, I would still want guestForceDevelopmentLocal to apply specifically to myself (based on IP or some other method) because sometimes I let people view my local dev environment from the outside and I don't want them to see the debug bar. 1 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