Skip to content

Commit

Permalink
Merge pull request #40 from humanmade/backport-38-to-v3-branch
Browse files Browse the repository at this point in the history
[Backport v3-branch] Remove constant and update docs
  • Loading branch information
roborourke authored Dec 4, 2019
2 parents 8056b2d + 0fcb639 commit 86b2296
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 55 deletions.
31 changes: 17 additions & 14 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ The Altis developer tools are built on top of the [Query Monitor](https://querym

The developer tools are active by default for all environment types except `production`. While logged in, a summary of the request's details will appear in the toolbar at the top of the page. Click this summary to open the developer tools.

![Screenshot of the developer tools toolbar item](./toolbar.png)
![Screenshot of the developer tools toolbar item](./assets/toolbar.png)

This summary will automatically change color if errors or warnings are detected on your page.

The developer tools will be displayed as a panel at the bottom of your page.

![Screenshot of the developer tools panel](./qm-overview.png)
![Screenshot of the developer tools panel](./assets/qm-overview.png)


### Activating for other users

By default, only administrators have access to the developer tools. You can temporarily test with other users or while logged out by setting an activation cookie instead.

To activate this cookie, open the developer tools while logged in as an administrator, then click on the gear icon in the top right to access the settings screen. Click the "Set authentication cookie" button to enable developer tools for your browser, then switch to another account or log out.
To activate this cookie:

![Screenshot of the developer tools panel](./qm-settings.png)
1. Open the developer tools while logged in as an administrator
2. Click on the gear icon in the top right to access the settings screen
3. Click the "Set authentication cookie" button to enable developer tools for your browser
4. Switch to another account or log out

![Screenshot of the developer tools panel](./assets/qm-settings-auth.png)

You can also add the `view_query_monitor` capability to users to permanently grant them the ability to use the developer tools.

Expand Down Expand Up @@ -61,16 +66,14 @@ For example, to disable on staging:

### Editor Stack Traces

When viewing a stack trace of a PHP warning or error, the developer tools can turn these into clickable links that open in your editor. To enable this, define `QM_LOCAL_EDITOR` like this:
Stack traces within the developer tools panel can be made into clickable links that open in your editor. Database queries will also be clickable so you can jump directly to the function that made them.

```php
define( 'QM_LOCAL_EDITOR', 'phpstorm' );
```
To activate clickable stack traces:

Valid values include:
1. Open the developer tools panel
2. Click on the gear icon in the top right to access the settings screen
3. Select your editor from the drop down
4. Click the "Set editor cookie" button
5. Refresh the page

- `phpstorm`
- `vscode`
- `atom`
- `sublime`
- `netbeans`
![Screenshot of the developer tools panel](./assets/qm-settings-editor.png)
File renamed without changes
Binary file added docs/assets/qm-settings-auth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/qm-settings-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed docs/qm-settings.png
Binary file not shown.
41 changes: 0 additions & 41 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
*/
function bootstrap() {
add_action( 'plugins_loaded', __NAMESPACE__ . '\\on_plugins_loaded', 1 );
add_filter( 'qm/output/file_link_format', __NAMESPACE__ . '\\set_edit_link_format', 1 );
}

/**
Expand All @@ -32,43 +31,3 @@ function on_plugins_loaded() {
require_once ROOT_DIR . '/vendor/johnbillion/query-monitor/query-monitor.php';
}
}

/**
* Implements a Query Monitor filter to adjust the
* URLs used in stack traces for editor support.
*
* @param string $format a protocol URL format
* @return string a protocol URL format
*/
function set_edit_link_format( $format ) : string {
$editor = null;
if ( defined( 'QM_LOCAL_EDITOR' ) ) {
$editor = QM_LOCAL_EDITOR;
}
return get_edit_link_format( $format, $editor );
}

/**
* Provides a protocol URL for edit links in QM stack
* traces for various editors.
*
* @param string $default_format a format to use if no editor is found
* @param string|null $editor the chosen code editor
* @return string a protocol URL format
*/
function get_edit_link_format( $default_format, $editor = null ) : string {
switch ( $editor ) {
case 'phpstorm':
return 'phpstorm://open?file=%f&line=%l';
case 'vscode':
return 'vscode://file/%f:%l';
case 'atom':
return 'atom://open/?url=file://%f&line=%l';
case 'sublime':
return 'subl://open/?url=file://%f&line=%l';
case 'netbeans':
return 'nbopen://%f:%l';
default:
return $default_format;
}
}

0 comments on commit 86b2296

Please sign in to comment.