Debugging
Debug class
In MV there is a class "Debug" containing some methods for debugging the written code. The "pre()" method displays a dump of variable. With its help it is convenient to view the content of arrays and objects. The "echo" function is not required for this.
Debug :: pre($var); Debug :: pre($mv -> pages);
Log files
Log class can create files in folder "log" at the root of the project. This folder must have right allowing to write into folder.
//Creates new record in log file named like current server, for example mysite.com.log Log :: add("Error or message text"); //Creates new record in log file with passed name, for example events.log Log :: add("Error or message text", "events");
Generation time and count of SQL queries
There is a parameter in "index.php" file that makes it possible to see page generation time, number of called queries, and also the included template file. For this you need to pass 1 (by default, 0) as a parameter when creating "$debug" object. After page reload, you can see the list of information about this page in the end.
<? require_once "config/autoload.php"; $debug = new Debug(1); ... ?>
Detection of browser type
The browser of the user can be detected by a static "browser()" method of the class "Debug". Returns a browser type, possible value are "firefox", "ie", "opera", "chrome", "safari", "edge" or "false" if not in the list of these types.
$browser = Debug :: browser(); if($browser == "chrome") { ... }
Detection of mobile device
The following mobile devices can be detected: Android, iPhone, iPod, BlackBerry, IEMobile, Windows Phone. Returned values are: "android", "iphone", "ipod", "blackberry", "ie", "windows" or "false" if not in the list of these types.
if(Debug :: isMobile() == "android") include ...; if(Debug :: isMobile()) //Any smartphone { ... }
Detection of tablet device
The following tablet devices can be detected: Android, iPad, Windows. Returned values are: "android", "ipad", "windows" or "false" if not in the list of these types.
if(Debug :: isTablet() == "ipad") include ...; if(Debug :: isTablet()) //Any tablet { ... }
Previous section
Security