# Class yii\debug\Module

Inheritance | yii\debug\Module » yii\base\Module » yii\di\ServiceLocator » yii\base\Component » yii\base\BaseObject
Implements | yii\base\BootstrapInterface, yii\base\Configurable
Available since version | 2.0
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/Module.php

The Yii Debug Module provides the debug toolbar and debugger

## Public Properties

Hide inherited properties

Property | Type | Description | Defined By
--- | --- | --- | ---
$aliases | array | List of path aliases to be defined. The array keys are alias names (must start with `@`) and the array values are the corresponding paths or aliases. See setAliases() for an example. This property is write-only. | yii\base\Module
$allowedHosts | array | The list of hosts that are allowed to access this module. | yii\debug\Module
$allowedIPs | array | The list of IPs that are allowed to access this module. | yii\debug\Module
$basePath | string | The root directory of the module. | yii\base\Module
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. This property is read-only. | yii\base\Component
$checkAccessCallback | callable | A valid PHP callback that returns true if user is allowed to use web shell and false otherwise The signature is the following: function (Action|null $action) The action can be null when called from a non action context (like set debug header) | yii\debug\Module
$components | array | The list of the component definitions or the loaded component instances (ID => definition or instance). | yii\di\ServiceLocator
$controllerMap | array | Mapping from controller ID to controller configurations. | yii\base\Module
$controllerNamespace | string|null | The namespace that controller classes are in. | yii\debug\Module
$controllerPath | string | The directory that contains the controller classes. This property is read-only. | yii\base\Module
$dataPath | string | The directory storing the debugger data files. | yii\debug\Module
$debugHeaders | yii\base\Event |  | yii\debug\Module
$defaultHeight | integer | The debug bar default height, as a percentage of the total screen height | yii\debug\Module
$defaultPanel | string | The name of the panel that should be visible when opening the debug panel. | yii\debug\Module
$defaultRoute | string | The default route of this module. | yii\base\Module
$dirMode | integer | The permission to be set for newly created directories. | yii\debug\Module
$disableCallbackRestrictionWarning | boolean | Whether to disable access callback restriction warning triggered by checkAccess function | yii\debug\Module
$disableIpRestrictionWarning | boolean | Whether to disable IP address restriction warning triggered by checkAccess function | yii\debug\Module
$enableDebugLogs | boolean | Whether to enable message logging for the requests about debug module actions. | yii\debug\Module
$fileMode | integer | The permission to be set for newly created debugger data files. | yii\debug\Module
$historySize | integer | The maximum number of debug data files to keep. | yii\debug\Module
$id | string | An ID that uniquely identifies this module among other modules which have the same parent. | yii\base\Module
$layout | string|boolean|null | The layout that should be applied for views within this module. | yii\base\Module
$layoutPath | string | The root directory of layout files. Defaults to "$viewPath/layouts". | yii\base\Module
$logTarget | yii\debug\LogTarget |  | yii\debug\Module
$module | yii\base\Module|null | The parent module of this module. | yii\base\Module
$modules | array | The modules (indexed by their IDs). | yii\base\Module
$pageTitle | string|callable | Page title could be a string or a callable function ```php . | yii\debug\Module
$panels | array|yii\debug\Panel[] | List of debug panels. | yii\debug\Module
$params | array | Custom module parameters (name => value). | yii\base\Module
$skipAjaxRequestUrl | array | Routes of AJAX requests to skip from being displayed in toolbar | yii\debug\Module
$toolbarHtml |  |  | yii\debug\Module
$traceLine | mixed | The string with placeholders to be be substituted or an anonymous function that returns the trace line string. | yii\debug\Module
$tracePathMappings | array | Used when the virtual, containerized, or remote debug trace paths don't correspond to the developers local paths. | yii\debug\Module
$uniqueId | string | The unique ID of the module. This property is read-only. | yii\base\Module
$urlRuleClass | string | The UrlRule class to use for rules generated by this module. | yii\debug\Module
$version | string | The version of this module. Note that the type of this property differs in getter and setter. See getVersion() and setVersion() for details. | yii\base\Module
$viewPath | string | The root directory of view files. Defaults to "$basePath/views". | yii\base\Module

## Public Methods

Hide inherited methods

Method | Description | Defined By
--- | --- | ---
__call() | Calls the named method which is not a class method. | yii\base\Component
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component
__construct() | Constructor. | yii\base\Module
__get() | Returns the value of a component property. | yii\base\Component
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component
__set() | Sets the value of a component property. | yii\base\Component
__unset() | Sets a component property to be null. | yii\base\Component
afterAction() | This method is invoked right after an action within this module is executed. | yii\base\Module
attachBehavior() | Attaches a behavior to this component. | yii\base\Component
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component
beforeAction() | This method is invoked right before an action within this module is executed. | yii\debug\Module
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component
bootstrap() | Bootstrap method to be called during application bootstrap stage. | yii\debug\Module
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component
className() | Returns the fully qualified name of this class. | yii\base\BaseObject
clear() | Removes the component from the locator. | yii\di\ServiceLocator
createController() | Creates a controller instance based on the given route. | yii\base\Module
createControllerByID() | Creates a controller based on the given controller ID. | yii\base\Module
detachBehavior() | Detaches a behavior from the component. | yii\base\Component
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component
get() | Returns the component instance with the specified ID. | yii\base\Module
getBasePath() | Returns the root directory of the module. | yii\base\Module
getBehavior() | Returns the named behavior object. | yii\base\Component
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component
getComponents() | Returns the list of the component definitions or the loaded component instances. | yii\di\ServiceLocator
getControllerPath() | Returns the directory that contains the controller classes according to $controllerNamespace. | yii\base\Module
getInstance() | Returns the currently requested instance of this module class. | yii\base\Module
getLayoutPath() | Returns the directory that contains layout view files for this module. | yii\base\Module
getModule() | Retrieves the child module of the specified ID. | yii\base\Module
getModules() | Returns the sub-modules in this module. | yii\base\Module
getToolbarHtml() | Gets toolbar HTML | yii\debug\Module
getUniqueId() | Returns an ID that uniquely identifies this module among all modules within the current application. | yii\base\Module
getVersion() | Returns current module version. | yii\base\Module
getViewPath() | Returns the directory that contains the view files for this module. | yii\base\Module
getYiiLogo() | Returns the logo URL to be used in `<img src="` | yii\debug\Module
has() | Returns a value indicating whether the locator has the specified component definition or has instantiated the component. | yii\base\Module
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component
hasModule() | Checks whether the child module of the specified ID exists. | yii\base\Module
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component
htmlTitle() |  | yii\debug\Module
init() | Initializes the module. | yii\debug\Module
off() | Detaches an existing event handler from this component. | yii\base\Component
on() | Attaches an event handler to an event. | yii\base\Component
renderToolbar() | Renders mini-toolbar at the end of page body. | yii\debug\Module
runAction() | Runs a controller action specified by a route. | yii\base\Module
set() | Registers a component definition with this locator. | yii\di\ServiceLocator
setAliases() | Defines path aliases. | yii\base\Module
setBasePath() | Sets the root directory of the module. | yii\base\Module
setComponents() | Registers a set of component definitions in this locator. | yii\di\ServiceLocator
setDebugHeaders() | Setting headers to transfer debug data in AJAX requests without interfering with the request itself. | yii\debug\Module
setInstance() | Sets the currently requested instance of this module class. | yii\base\Module
setLayoutPath() | Sets the directory that contains the layout files. | yii\base\Module
setModule() | Adds a sub-module to this module. | yii\base\Module
setModules() | Registers sub-modules in the current module. | yii\base\Module
setVersion() | Sets current module version. | yii\base\Module
setViewPath() | Sets the directory that contains the view files. | yii\base\Module
setYiiLogo() | Sets the logo URL to be used in `<img src="` | yii\debug\Module
trigger() | Triggers an event. | yii\base\Component

## Protected Methods

Hide inherited methods

Method | Description | Defined By
--- | --- | ---
checkAccess() | Checks if current user is allowed to access the module | yii\debug\Module
corePanels() |  | yii\debug\Module
defaultVersion() | Returns default module version. | yii\debug\Module
initPanels() | Initializes panels. | yii\debug\Module
resetGlobalSettings() | Resets potentially incompatible global settings done in app config. | yii\debug\Module

## Events

Hide inherited events

Event | Type | Description | Defined By
--- | --- | --- | ---
EVENT_AFTER_ACTION | yii\base\ActionEvent | An event raised after executing a controller action. | yii\base\Module
EVENT_BEFORE_ACTION | yii\base\ActionEvent | An event raised before executing a controller action. | yii\base\Module

## Constants

Hide inherited constants

Constant | Value | Description | Defined By
--- | --- | --- | ---
DEFAULT_IDE_TRACELINE | '{text}' |  | yii\debug\Module

## Property Details

$allowedHosts public property

The list of hosts that are allowed to access this module. Each array element is a hostname that will be resolved to an IP address that is compared with the IP address of the user. A use case is to use a dynamic DNS (DDNS) to allow access. The default value is `[]`.

public array $allowedHosts = []
$allowedIPs public property

The list of IPs that are allowed to access this module. Each array element represents a single IP filter which can be either an IP address or an address with wildcard (e.g. 192.168.0.*) to represent a network segment. The default value is `['127.0.0.1', '::1']`, which means the module can only be accessed by localhost.

public array $allowedIPs = ['127.0.0.1', '::1']
$checkAccessCallback public property (available since version 2.1.0)

A valid PHP callback that returns true if user is allowed to use web shell and false otherwise

The signature is the following:

function (Action|null $action) The action can be null when called from a non action context (like set debug header)

public callable $checkAccessCallback = null
$controllerNamespace public property

The namespace that controller classes are in. This namespace will be used to load controller classes by prepending it to the controller class name.

If not set, it will use the `controllers` sub-namespace under the namespace of this module. For example, if the namespace of this module is `foo\bar`, then the default controller namespace would be `foo\bar\controllers`.

See also the guide section on autoloading to learn more about defining namespaces and how classes are loaded.

public string|null $controllerNamespace = 'yii\debug\controllers'
$dataPath public property

The directory storing the debugger data files. This can be specified using a path alias.

public string $dataPath = '@runtime/debug'
$debugHeaders public write-only property (available since version 2.0.7)
public void setDebugHeaders ( $event )
$defaultHeight public property (available since version 2.1.1)

The debug bar default height, as a percentage of the total screen height

public integer $defaultHeight = 50
$defaultPanel public property (available since version 2.0.7)

The name of the panel that should be visible when opening the debug panel. The default value is 'log'.

public string $defaultPanel = 'log'
$dirMode public property (available since version 2.0.6)

The permission to be set for newly created directories. This value will be used by PHP chmod() function. No umask will be applied. Defaults to 0775, meaning the directory is read-writable by owner and group, but read-only for other users.

public integer $dirMode = 0775
$disableCallbackRestrictionWarning public property (available since version 2.1.0)

Whether to disable access callback restriction warning triggered by checkAccess function

public boolean $disableCallbackRestrictionWarning = false
$disableIpRestrictionWarning public property (available since version 2.0.14)

Whether to disable IP address restriction warning triggered by checkAccess function

public boolean $disableIpRestrictionWarning = false
$enableDebugLogs public property

Whether to enable message logging for the requests about debug module actions. You normally do not want to keep these logs because they may distract you from the logs about your applications. You may want to enable the debug logs if you want to investigate how the debug module itself works.

public boolean $enableDebugLogs = false
$fileMode public property (available since version 2.0.6)

The permission to be set for newly created debugger data files. This value will be used by PHP chmod() function. No umask will be applied. If not set, the permission will be determined by the current environment.

public integer $fileMode = null
$historySize public property

The maximum number of debug data files to keep. If there are more files generated, the oldest ones will be removed.

public integer $historySize = 50
$logTarget public property
public yii\debug\LogTarget $logTarget = null
$pageTitle public property (available since version 2.1.1)

Page title could be a string or a callable function

    ...
    'pageTitle' => 'Custom Debug Title',
    ...
    // OR
    'pageTitle' => function($url) {
        $domain = getDomain($url);
        return $domain . ' debugger';
    }

public string|callable $pageTitle = null
$panels public property

List of debug panels. The array keys are the panel IDs, and values are the corresponding panel class names or configuration arrays. This will be merged with corePanels(). You may reconfigure a core panel via this property by using the same panel ID. You may also disable a core panel by setting it to be false in this property.

public array|yii\debug\Panel[] $panels = []
$skipAjaxRequestUrl public property (available since version 2.1.14)

Routes of AJAX requests to skip from being displayed in toolbar

public array $skipAjaxRequestUrl = []
$toolbarHtml public read-only property (available since version 2.0.7)
public void getToolbarHtml ( )
$traceLine public property (available since version 2.0.7)

The string with placeholders to be be substituted or an anonymous function that returns the trace line string. The placeholders are {file}, {line} and {text} and the string should be as follows:

`File: {file} - Line: {line} - Text: {text}`

The signature of the anonymous function should be as follows:

    function($trace, $panel) {
        // compute line string
        return $line;
    }

public mixed $traceLine = self::DEFAULT_IDE_TRACELINE
$tracePathMappings public property (available since version 2.1.6)

Used when the virtual, containerized, or remote debug trace paths don't correspond to the developers local paths. Acts on the {file} portion for the `$traceLine` property.

The array key is the environment's path, while the value is the local desired path.

It will only map the first matched matched key.

Example:

    [
        '/app' => '/home/user/project/app',
    ]

Note that this will not change the displayed text, only the link url.

public array $tracePathMappings = []
$urlRuleClass public property (available since version 2.1.1)

The UrlRule class to use for rules generated by this module.

public string $urlRuleClass = 'yii\web\UrlRule'

## Method Details

beforeAction() public method

This method is invoked right before an action within this module is executed.

The method will trigger the EVENT_BEFORE_ACTION event. The return value of the method will determine whether the action should continue to run.

In case the action should not run, the request should be handled inside of the `beforeAction` code by either providing the necessary output or redirecting the request. Otherwise the response will be empty.

If you override this method, your code should look like the following:

    public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }

        // your custom code here

        return true; // or false to not run the action
    }

public boolean beforeAction ( $action )
$action | yii\base\Action | The action to be executed.
return | boolean | Whether the action should continue to be executed.
throws | yii\base\InvalidConfigException |
throws | yii\web\ForbiddenHttpException |

bootstrap() public method

Bootstrap method to be called during application bootstrap stage.

public void bootstrap ( $app )
$app | yii\base\Application | The application currently running

checkAccess() protected method

Checks if current user is allowed to access the module

protected boolean checkAccess ( $action = null )
$action | yii\base\Action|null | The action to be executed. May be `null` when called from a non action context
return | boolean | If access is granted

corePanels() protected method

protected array corePanels ( )
return | array | Default set of panels

defaultVersion() protected method (available since version 2.0.7)

Returns default module version.

Child class may override this method to provide more specific version detection.

protected string defaultVersion ( )
return | string | The version of this module.

getToolbarHtml() public method (available since version 2.0.7)

Gets toolbar HTML

public void getToolbarHtml ( )

getYiiLogo() public static method

Returns the logo URL to be used in `<img src="`

public static string getYiiLogo ( )
return | string | The logo URL

htmlTitle() public method (available since version 2.1.1)

public string htmlTitle ( )
return | string | Page title to be used in HTML

init() public method

Initializes the module.

This method is called after the module is created and initialized with property values given in configuration. The default implementation will initialize $controllerNamespace if it is not set.

If you override this method, please make sure you call the parent implementation.

public void init ( )
throws | yii\base\InvalidConfigException |

initPanels() protected method

Initializes panels.

protected void initPanels ( )
throws | yii\base\InvalidConfigException |

renderToolbar() public method

Renders mini-toolbar at the end of page body.

public void renderToolbar ( $event )
$event | yii\base\Event |
throws | Throwable |

resetGlobalSettings() protected method

Resets potentially incompatible global settings done in app config.

protected void resetGlobalSettings ( )

setDebugHeaders() public method (available since version 2.0.7)

Setting headers to transfer debug data in AJAX requests without interfering with the request itself.

public void setDebugHeaders ( $event )
$event | yii\base\Event |

setYiiLogo() public static method

Sets the logo URL to be used in `<img src="`

public static void setYiiLogo ( $logo )
$logo | string | The logo URL