Debugging
By default, when you create a project, it will come with development mode activated and in this mode several features will be available to assist your development.
Developtment mode
In development mode, instead of an instance of Inphinit\App
in the $app
variable, you will have an instance of Inphinit\Debug\App
. This instance does exactly the same thing as Inphinit\App
, but it also validates all values in all methods of the class, throwing exceptions if any value is unexpected. If development mode is turned off, none of the methods will perform validations or throw errors, which will allow for much better performance when development mode is turned off, while if it is turned on, it will allow you to develop without making so many mistakes.
Debugging errors
In development mode, all errors, warnings and exceptions can be displayed directly in the browser, displaying the content of the problematic script and line (problematic HTML and XML files loaded by a Inphinit\DOM\Document
instance, will also be displayed, more details DOM errors).
You need to execute the $debug->setErrorView($view)
method in the system/dev.php
and it is possible to customize the view. By default the view is already defined as 'debug.error'
(from system/views/debug/error.php
):
// Inject CSS for debug if necessary
$debug->setBeforeView('debug.style');
// Display errors
$debug->setErrorView('debug.error');
Debugging routes
In development mode, all created routes will be validated, in the action($methods, $path, $callback)
method, the HTTP methods will be validated, allowing only methods ANY, DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
In the case of passing duplicate methods in an array, such as $app->action(['GET', 'GET'], '/foo', ...)
, an exception will also be thrown.
Other validations:
- Duplicate patterns
- Invalid patterns
- Invalid controllers
- Incorrect method visibility on controllers
- Not callable callbacks
- Invalid prefix namespaces defined using
setNamespace($prefix)
method - Invalid prefix paths defined using
setPath($prefix)
method
Integrating online assistants
{placeholder} system/configs/debug.php
change key:
'assistant' => 'https://duckduckgo.com/?q={error}',
Integrating the text editor
{placeholder} system/configs/debug.php
change key:
'editor' => 'vscode',
Using sublimetext
'editor' => 'sublimetext',
Other editors, {path}
and {line}
'editor' => 'foo://bar/baz?path={path}&line={line}',
Displays defined methods, constants and classes
{placeholder}
$debug->setDefinedView('debug.defined');
Displays performance
{placeholder}
$debug->setPerformanceView('debug.performance');