PHP code example of wenprise / mvc

1. Go to this page and download the library: Download wenprise/mvc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wenprise / mvc example snippets




namespace Theme;

use Theme\Providers\RoutingService;
use Wenprise\Mvc\App;

class Init
{

    public function __construct()
    {
        $GLOBALS[ 'wenprise' ] = App::instance();

        /*
         * 获取服务容器
         */
        $container = $GLOBALS[ 'wenprise' ]->container;

        /*
         * 注册主题视图路径
         */
        $container[ 'view.finder' ]->addLocation(get_theme_file_path('templates'));


        /*
         * 加载配置文件
         */
        $container[ 'config.finder' ]->addPaths([
            get_theme_file_path('app/Config/'),
        ]);

        /**
         * 主题服务提供者
         */
        $providers = [
            RoutingService::class,
        ];

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

}

namespace Theme\Providers;

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

class RoutingService extends ServiceProvider {
	public function register() {
		Route::group( [
			'namespace' => 'Theme\Controllers',
		], function () {
			

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

namespace Theme\Controllers;

use Wenprise\Route\BaseController;

class AccountController extends BaseController {

	/**
	 * User register controller
	 * @return string
	 */
	public function register() {
	
	}
	
}
bash
├── Controllers
│   ├── AccountController.php
├── Models
│   ├── Order.php
├── Providers
│   └── RoutingService.php
├── init.php
└── routes.php