Debugging
Debug class
MV has a Debug class that contains methods for debugging scripts.
//Dump output
Debug::pre($var);
Debug::pre($mv -> pages);
//Dump output and exit
Debug::exit($var);
//Call an error and stop the script
//In production mode, a 404 error will be shown and a log will be written
Debug::displayError('Error text...');
Writing to log
The Log class can create log files in the log folder in the root of the project. This folder must have write permissions.
//Creates a log file entry with the server name, for example mysite.com.log
Log::add('Error or message text');
//Creates a log file entry with the specified name, for example events.log
//Useful for separating log files by type and service
Log::add('Error or message text', 'events');
Generation time and SQL query count
In the debug panel, you can see the page generation time, the number of executed SQL queries, and the included template file. To display the panel, you need to enable the setting in the configuration file.
//config/setup.php file
//Resetting the settings, routes and media files cache
//Increase by 1 each time you upload to the production server
'Build' => 3,
//Show the debug panel at the bottom of the browser window
//In production mode, the panel will only be displayed if you are logged in to the admin panel
'DebugPanel' => true,
Helpers
Special methods helping to debug the application.
//Checks if the current host is localhost
Http::isLocalHost(): bool
//Checks if the application works on development environment
Registry::onDevelopment(): bool
//Checks if the application works on production environment
Registry::onProduction(): bool
Determining the browser type
The user's browser can be determined using the static browser method of the Debug class. Returns the browser type, possible values: firefox, ie, opera, chrome, safari, yandex or an empty string if it does not belong to any of the listed types.
$browser = Debug::browser();
if($browser === 'safari')
{
...
}
Mobile device detection
The following mobile devices are detected: Android, iPhone, iPod, BlackBerry, IEMobile, Windows Phone. Returns values: android, iphone, pod, blackberry, ie, windows or an empty string if it does not apply to any of the listed devices.
if(Debug::isMobile() === 'iphone')
include ...;
if(Debug::isMobile())
{
...
}
Tablet detection
The following tablets are detected: Android, iPad, Windows. Returns values: android, ipad, windows or an empty string if it does not apply to any of the listed devices.
if(Debug::isTablet() === 'ipad')
echo ...;
if(Debug::isTablet())
{
...
}
Previous section
Migrations