MV framework logo
  • Architecture
  • Philosophy
  • Admin panel
  • Support
  • Feedback
Documentation
Download .zip version 3.2.0 from 25.12.2024
  • Architecture
  • Philosophy
  • Admin panel
  • Support
  • Feedback
Getting started
  • Installation and launch
  • Folder structure
  • Launching a simple website
  • Pre-installed models
  • SQLite getting started
  • System settings
  • Migrations
  • Debugging
Models
  • General principles of models
  • Data types
  • Model setup
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Managing simple models
  • Additional features
Templates and routing
  • General principles of templates
  • Router object
  • MV object
  • Create a new template
  • Output of data in template
  • Record object
  • Files and images
  • Date and time
  • Redirects and http
  • Sending email
  • Special methods
Forms
  • Creating forms
  • Setting up form fields
  • Validating form fields
  • Form security
  • Working with form data
  • Using data from models
  • Form methods
SQL queries
  • Query builder
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
Additional
  • AJAX
  • Plugins
  • Caching
  • Security
  • Admin panel add-ons
Documentation
Getting started
  • Installation and launch
  • Folder structure
  • Launching a simple website
  • Pre-installed models
  • SQLite getting started
  • System settings
  • Migrations
  • Debugging
Models
  • General principles of models
  • Data types
  • Model setup
  • Simple models
  • Foreign keys
  • Trees
  • Many to many
  • Group
  • Records management
  • Managing simple models
  • Additional features
Templates and routing
  • General principles of templates
  • Router object
  • MV object
  • Create a new template
  • Output of data in template
  • Record object
  • Files and images
  • Date and time
  • Redirects and http
  • Sending email
  • Special methods
Forms
  • Creating forms
  • Setting up form fields
  • Validating form fields
  • Form security
  • Working with form data
  • Using data from models
  • Form methods
SQL queries
  • Query builder
  • Direct queries
  • Pagination
  • Sorting
  • Filtration
Additional
  • AJAX
  • Plugins
  • Caching
  • Security
  • Admin panel add-ons
MV tracker

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

Next section

General principles of models
MV workshop banner
MV tracker

© 2014-2025, MV framework team

MV tracker project Github