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

Plugins

Plugins in MV are classes for performing tasks that do not require managing a table in the database, as is the case with models.

Plugins are instantiated in the $mv object immediately upon its creation, and not like models using the lazy load principle.

Basic rules

  1. The plugin class must inherit from the Plugin class.
  2. The file must have a name like plugin_name.plugin.php and be located in the plugins folder in the root of the project.
  3. To activate a plugin, its class must be specified in the config/plugins.php file.
  4. The plugin object is available in the $mv -> plugin_name object.
  5. The plugin is constructed immediately upon creation of the $mv object.
//File plugins/cart.plugin.php

class Cart extends Plugin
{
    private $items = [];
    
    private $products_model;
    
    public function __construct()
    {
        //Unlike models, the constructor can be supplemented
        parent :: __construct();
        
        //Product model object
        $this -> products_model = new Products(); 
    }
    
    public function addItemToCart($id, $quantity)
    {
        ...
    }
}

//Example of using the plugin in a template file
$mv -> cart -> addItemToCart(56, 2);

Previous section

AJAX

Next section

Caching
MV workshop banner
MV tracker

© 2014-2025, MV framework team

MV tracker project Github