PHPackages                             media-store-net/wp-mvc-core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. media-store-net/wp-mvc-core

ActiveLibrary[Framework](/categories/framework)

media-store-net/wp-mvc-core
===========================

A small MVC framework for Wordpress plugins and themes.

v1.0.4(5mo ago)0321MITPHPPHP &gt;=7.4

Since Mar 3Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/media-store-net/wp-mvc-core)[ Packagist](https://packagist.org/packages/media-store-net/wp-mvc-core)[ RSS](/packages/media-store-net-wp-mvc-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (1)

WP MVC Core (For Wordpress plugins and themes)
==============================================

[](#wp-mvc-core-for-wordpress-plugins-and-themes)

---

**This is a forked version of [amostajo/lightweight-mvc@1.5](https://github.com/amostajo/lightweight-mvc.git)**

**Lightweight MVC** is a small framework that adds *Models*, *Views* and *Controllers* to your custom **Wordpress** plugin or theme.

Lightweight MVC utilices existing Wordpress functionality preventing from overloading the already heavy loaded Wordpress core.

This framework was inspired by **Laravel** to add the MVC design pattern to Wordpress development in an efficient, elegant and optimized way.

- [Requirements](#requirements)
- [Installation](#configuration)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Models](#models)
        - [Aliases](#aliases)
        - [Types](#types)
    - [Views](#views)
    - [Controllers](#controllers)
    - [Engine](#engine)
    - [Helpers](#helpers)
- [Coding Guidelines](#coding-guidelines)
- [License](#license)

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4

Installation
------------

[](#installation)

Add

```
"media-store-net/wp-mvc-core" : "1.0.*"
```

to your composer.json. Then run `composer install` or `composer update`.

**NOTE** If you are not using composer, you can download the ZIP but will need to include the files manually since not autoload will be generated.

Configuration
-------------

[](#configuration)

Your project needs to store somewhere your `Models`, `Views` and `Controllers`, and **Lightweight MVC** must know where.

Create these as folders, like this:

```
[PROJECT ROOT]
 |---> [controllers]
 |---> [models]
 |---> [views]
```

Then in your `functions.php` or `plugins.php` file set these at the very beginnning, like:

```
// Path to the controllers folder.
$engine = new MediaStoreNet\MVC_Core\Engine(

	// Path to the views folder.
	$views_path = 'path_to_views_folder',

	// Path to the controllers folder.
	$controllers_path = 'path_to_controllers_folder',

	// Namespace of your plugin or theme. For controller access
	$namespace = 'MyApp'
);
```

Usage
-----

[](#usage)

### Models

[](#models)

In **Lightweight MVC**, a `Model` at the end is just a type of Wordpress post. Store your models at the `models` folder.

Here is model example:

```
