Skip to content
A micro framework which modernizes WordPress as a CMS development by providing tools to implement MVC and more.
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
README.md
composer.json
composer.lock

README.md

Wenprise MVC framework for WrodPress

Add a MVC framework to wordpress, based on Themosis Framework .

Usage

User composer to install

In your theme directory

$ composer require wenprise/mvc

add psr-4 autoload rule to composer.json

"autoload": {
    "psr-4": {
      "Theme\\": "app/"
    }
},

the run the dump-autoload command

$ composer dump-autoload

Include the autoload and frame init fie to your theme`s functions.php file.

require_once( get_theme_file_path( 'vendor/autoload.php' ) );
require_once( get_theme_file_path( 'app/init.php' ) );

The directory structure

The structure of theme/app directory.

├── Controllers
│   ├── AccountController.php
├── Models
│   ├── Order.php
├── Providers
│   └── RoutingService.php
├── init.php
└── routes.php

Boot the framework in theme

the code in init.php

defined( 'DS' ) ? DS : define( 'DS', DIRECTORY_SEPARATOR );


if ( function_exists( 'container' ) ) {

	/*
	 * get the container
	 */
	$theme = container();

	/*
	 * register theme view path
	 * where the blade template files placed
	 */
	$theme[ 'view.finder' ]->addLocation( get_theme_file_path( 'views' ) );

	$aliases = [];

	/*
	 * theme class alias
	 */
	if ( ! empty( $aliases ) && is_array( $aliases ) ) {
		foreach ( $aliases as $alias => $fullname ) {
			class_alias( $fullname, $alias );
		}
	}

	/**
	 * resiter theme service providers
	 */
	$providers = [
		Theme\Providers\RoutingService::class,
	];

	foreach ( $providers as $provider ) {
		$theme->register( $provider );
	}

}

Routing Service

the code in RoutingService.php

namespace Theme\Providers;

use Wenprise\Facades\Route;
use Wenprise\Foundation\ServiceProvider;

class RoutingService extends ServiceProvider {
	public function register() {
		Route::group( [
			'namespace' => 'Theme\Controllers',
		], function () {
			require get_theme_file_path( 'app/routes.php' );
		} );
	}
}

Routers

the code in routes.php

Route::prefix( 'account' )->group( function () {
	Route::match( [ 'get', 'post' ], 'register', 'AccountController@register' );
} );

Controller

Sampel Controller

namespace Theme\Controllers;

use Wenprise\Route\BaseController;

class AccountController extends BaseController {

	/**
	 * User register controller
	 * @return string
	 */
	public function register() {
	
	}
	
}

Models

See: Wenprise Eloquent

Views

See https://laravel.com/docs/5.5/blade or https://twig.symfony.com/

You can’t perform that action at this time.