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

MV object

All templates use the $mv object to access models and other functions.

Own public properties

  • $root_path - path (URL) to the site root (usually '/' on the production domain), APP_FOLDER parameter in the .env file
  • $media_path - path (URL) from the site root to the media folder
  • $views_path - absolute path from the root of the file system to the folder with views templates
  • $include_path - absolute path from the root of the file system to the site, used for the include and require functions
  • $domain - domain name from the APP_DOMIAN parameter of the .env file
These properties are closely related to section System settings.

Own methods of the $mv object

  • redirect(), reload(), display404() - redirect to other pages within the site, more details in the section Redirects
  • checkUrlPart($index) - check the URL for the required part, more details in the section Router object

Objects inside the $mv object

  • registry - access to settings from configuration files, more details in the section System settings
  • router - router, Router object
  • db - database manager that performs Direct queries to the database
  • cache - caching in templates

All active models and plugins are available in the $mv object by their names.

Accessing models and plugins through the $mv object allows you to create the necessary objects only when needed and improves performance.
//Including part of the template
include $mv -> views_path.'main-header.php';
include $mv -> views_path.'parts/left-column.php';

//Using built-in objects
$mv -> db -> getCell("SELECT `email` FROM `users` WHERE `id`='236'");

//Accessing models
echo $mv -> pages -> displayMenu(74);
$user = $mv -> users -> find(['email' => 'aaa@bbb.cc', 'active' => 1]);

//Accessing plugins
$mv -> shopping_cart -> addProduct(34, 1) -> recountCart();

//Access to simple model data
echo $mv -> options -> phone;

//Redirect
$mv -> redirect('/home/page');

//Reload page with additional GET parameters
$mv -> reload('?success')

//Transition to 404 error
$mv -> display404();

Previous section

Router object

Next section

Create a new template
MV workshop banner
MV tracker

© 2014-2025, MV framework team

MV tracker project Github